Partha Paul created CODEC-336:
---------------------------------

             Summary: Base64.Builder.setUrlSafe() Javadoc incorrectly states 
null is accepted for primitive boolean parameter
                 Key: CODEC-336
                 URL: https://issues.apache.org/jira/browse/CODEC-336
             Project: Commons Codec
          Issue Type: Bug
    Affects Versions: 1.21.0
         Environment: * Java version: (javac 17.0.12)
 * Commons-Codec (latest version 1.21.0 including the past)
            Reporter: Partha Paul


The Javadoc for *{{Base64.Builder.setUrlSafe(boolean urlSafe)}}* contains a 
misleading {{@param}} description that states {{{}null resets to the 
default{}}}, however the method signature uses the primitive type {{boolean}} 
which cannot accept null values in Java.

*Javadoc (current) contains:*
 {{@param urlSafe URL-safe encoding policy, null resets to the default.}}

*Method signature (current):*
{{public Builder setUrlSafe(final boolean urlSafe)}}

 

Steps to reproduce:

{{Base64.builder().setUrlSafe((Boolean) null).get().isUrlSafe()}} // this will 
throw a NULL pointer exception at runtime.
Or directly passing {{null}}, which will be a compile-time error since 
primitive types cannot hold null values. 

 

*Suggested fix:*

Update the documentation to the following to match the method signature.
{{@param urlSafe URL-safe encoding policy.}}

 

Happy to submit PR with this fix!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to