commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LANG-676) Potential Autoboxing problems with BooleanUtils methods
Date Sun, 06 Feb 2011 06:59:30 GMT

    [ https://issues.apache.org/jira/browse/LANG-676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12991116#comment-12991116
] 

Henri Yandell commented on LANG-676:
------------------------------------

svn ci -m "Adding note on potential NPE if autoboxing occurs per LANG-676"
Sending        src/main/java/org/apache/commons/lang3/BooleanUtils.java
Transmitting file data .
Committed revision 1067606.


> Potential Autoboxing problems with BooleanUtils methods
> -------------------------------------------------------
>
>                 Key: LANG-676
>                 URL: https://issues.apache.org/jira/browse/LANG-676
>             Project: Commons Lang
>          Issue Type: Bug
>            Reporter: Henri Yandell
>             Fix For: 3.0
>
>
> FindBugs points out the following are bad:
> org.apache.commons.lang3.BooleanUtils.toBooleanObject(String, String, String, String)
> org.apache.commons.lang3.BooleanUtils.toBooleanObject(String
> org.apache.commons.lang3.BooleanUtils.toBooleanObject(Integer, Integer, Integer, Integer)
> org.apache.commons.lang3.BooleanUtils.toBooleanObject(Integer)
> org.apache.commons.lang3.BooleanUtils.toBooleanObject(int, int, int, int)
> org.apache.commons.lang3.BooleanUtils.negate(Boolean)
> For each case it's because the method returns Boolean, and returns null. That used to
be a feature, but apparently that plays merry havoc with autoboxing:
> ++NP: Method with Boolean return type returns explicit null (NP_BOOLEAN_RETURN_NULL)
> ++A method that returns either Boolean.TRUE, Boolean.FALSE or null is an accident waiting
to happen. This method can be invoked as though it returned a value of type boolean, and the
compiler will insert automatic unboxing of the Boolean value. If a null value is returned,
this will result in a NullPointerException. 
> The only solution imo is to let autoboxing do its job and remove these methods.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message