[jboss-jira] [JBoss JIRA] Commented: (JBRULES-984) NullPointerException on conditions using contains evaluator when collection is null
Edgardo Carena (JIRA)
jira-events at lists.jboss.org
Thu Jul 12 12:59:21 EDT 2007
[ http://jira.jboss.com/jira/browse/JBRULES-984?page=comments#action_12368760 ]
Edgardo Carena commented on JBRULES-984:
----------------------------------------
As a "user" I just want to point out, by a functional point of view, that I had the same issue.
My workaround has been to ensure that all empty lists were actually empty lists, rather than null pointers. Of course this is in principle also more correct and clean, however having a direct management of null lists, recognizing that they are equivalent to empty lists, would be greatly useful.
> NullPointerException on conditions using contains evaluator when collection is null
> -----------------------------------------------------------------------------------
>
> Key: JBRULES-984
> URL: http://jira.jboss.com/jira/browse/JBRULES-984
> Project: JBoss Rules
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Affects Versions: 4.0.0.MR3
> Reporter: Emily Harsh
> Assigned To: Mark Proctor
> Attachments: ObjectFactory.java
>
>
> Rule condition is as follows:
> myItem : MyItem( )
> MyObject( myCollection contains myItem )
> A NullPointerException is thrown when myCollection is null.
> Proposed solution:
> All evaluate* methods in org.drools.base.evaluators.ObjectFactory$ObjectContainsEvaluator need to have null checks surrounding the col.contains( value ) statements. For example, evaluateCachedLeft should be changed to:
> public boolean evaluateCachedLeft(final VariableContextEntry context,
> final Object right) {
> final Object value = ((ObjectVariableContextEntry) context).left;
> final Collection col = (Collection) context.extractor.getValue( right );
> return col == null ? false : col.contains( value );
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list