[hibernate-issues] [Hibernate-JIRA] Updated: (HV-53) AssertTrue and AssertFalse not compatible with null values

Emmanuel Bernard (JIRA) noreply at atlassian.com
Tue May 27 09:13:33 EDT 2008


     [ http://opensource.atlassian.com/projects/hibernate/browse/HV-53?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Bernard updated HV-53:
-------------------------------

    Fix Version/s: 3.1.0.CR2

> AssertTrue and AssertFalse not compatible with null values
> ----------------------------------------------------------
>
>                 Key: HV-53
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-53
>             Project: Hibernate Validator
>          Issue Type: Bug
>          Components: validators
>    Affects Versions: 3.0.0.ga
>            Reporter: benoit heinrich
>             Fix For: 3.1.0.CR2
>
>
> The AssertTrue and AssertFalse validators do not work with null values, they actually generate a NullPointerException.
> The code fix for this should be:
> public class AssertFalseValidator implements Validator<AssertFalse>, Serializable {
>         public boolean isValid(Object value) {
>                 if (value == null) return true;  << this is the fix
>                 return !(Boolean) value;
>         }
>         public void initialize(AssertFalse parameters) {
>         }
> }
> public class AssertTrueValidator implements Validator<AssertTrue>, Serializable {
>         public boolean isValid(Object value) {
>                 if (value == null) return true;  << this is the fix
>                 return (Boolean) value;
>         }
>         public void initialize(AssertTrue parameters) {
>         }
> }
> Cheers,
> /Benoit

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list