A DESCRIPTION OF THE REQUEST :
Latest javadoc (http://java.sun.com/javase/7/docs/api/java/lang/Boolean.html) states:
Returns a Boolean with a value represented by the specified string. The Boolean returned represents a true value if the string argument is not null and is equal, ignoring case, to the string "true".
Parameters:
s - a string.
Returns:
the Boolean value represented by the string.
While passing in a non-null and equal to "true" is explicitly mentioned, it is only loosely implying (some would say not implying at all) that passing in null would return false as opposed to throwing an exception
JUSTIFICATION :
It is not obvious what Boolean.valueOf(null) would return without looking at the java source or past experience with this topic. Other methods' valueOf throw exceptions if the string does not make sense as a parsable equivalent of those objects, so one might believe null with Boolean would work the same way.
Also note that the method getBoolean(String) does include this statement:
If there is no property with the specified name, or if the specified
name is empty or null, then {@code false} is returned.
so there should be similar explicit comments in valueOf(String)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Here's one example comment that explicitly addresses the null case:
Returns a {@code Boolean} with a value represented by the
specified string. The {@code Boolean} returned represents a
true value if the string argument is not {@code null}
and is equal, ignoring case, to the string {@code "true"}; returns
false in all other cases including if the argument is {code null}.
ACTUAL -
Javadoc for valueOf(String) says:
Returns a {@code Boolean} with a value represented by the
specified string. The {@code Boolean} returned represents a
true value if the string argument is not {@code null}
and is equal, ignoring case, to the string {@code "true"}.
---------- BEGIN SOURCE ----------
/**
* Returns a {@code Boolean} with a value represented by the
* specified string. The {@code Boolean} returned represents a
* true value if the string argument is not {@code null}
* and is equal, ignoring case, to the string {@code "true"}.
*
* @param s a string.
* @return the {@code Boolean} value represented by the string.
*/
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
n/a: developers can look at the src to see the actual behavior
Latest javadoc (http://java.sun.com/javase/7/docs/api/java/lang/Boolean.html) states:
Returns a Boolean with a value represented by the specified string. The Boolean returned represents a true value if the string argument is not null and is equal, ignoring case, to the string "true".
Parameters:
s - a string.
Returns:
the Boolean value represented by the string.
While passing in a non-null and equal to "true" is explicitly mentioned, it is only loosely implying (some would say not implying at all) that passing in null would return false as opposed to throwing an exception
JUSTIFICATION :
It is not obvious what Boolean.valueOf(null) would return without looking at the java source or past experience with this topic. Other methods' valueOf throw exceptions if the string does not make sense as a parsable equivalent of those objects, so one might believe null with Boolean would work the same way.
Also note that the method getBoolean(String) does include this statement:
If there is no property with the specified name, or if the specified
name is empty or null, then {@code false} is returned.
so there should be similar explicit comments in valueOf(String)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Here's one example comment that explicitly addresses the null case:
Returns a {@code Boolean} with a value represented by the
specified string. The {@code Boolean} returned represents a
true value if the string argument is not {@code null}
and is equal, ignoring case, to the string {@code "true"}; returns
false in all other cases including if the argument is {code null}.
ACTUAL -
Javadoc for valueOf(String) says:
Returns a {@code Boolean} with a value represented by the
specified string. The {@code Boolean} returned represents a
true value if the string argument is not {@code null}
and is equal, ignoring case, to the string {@code "true"}.
---------- BEGIN SOURCE ----------
/**
* Returns a {@code Boolean} with a value represented by the
* specified string. The {@code Boolean} returned represents a
* true value if the string argument is not {@code null}
* and is equal, ignoring case, to the string {@code "true"}.
*
* @param s a string.
* @return the {@code Boolean} value represented by the string.
*/
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
n/a: developers can look at the src to see the actual behavior