[
https://jira.jboss.org/browse/JBRULES-2500?page=com.atlassian.jira.plugin...
]
Stephane Trou commented on JBRULES-2500:
----------------------------------------
I write this patch to solve this issue. (Work with Drools 5.1.0-M2)
soundslike throws NullPointerException when one argument contains no
consonants
-------------------------------------------------------------------------------
Key: JBRULES-2500
URL:
https://jira.jboss.org/browse/JBRULES-2500
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: drools-core
Affects Versions: 5.0.1.FINAL
Environment: mvel2-2.0.12
Reporter: Steve Ronderos
Assignee: Mark Proctor
Attachments: JRules2500.patch
When using soundslike, if one argument can't be handled by Soundex an Exception is
thrown.
My exact situation is that the 1st parameter (before the soundslike operator) resolves to
a string that soundex does not support. It could be a string with only vowels, numbers
and spaces. I would expect soundslike to simply return false.
The stacktrace:
java.lang.NullPointerException
at
org.drools.base.evaluators.SoundslikeEvaluatorsDefinition$StringSoundsLikeEvaluator.evaluate(SoundslikeEvaluatorsDefinition.java:148)
at org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:92)
at org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:109)
at org.drools.rule.OrConstraint.__AW_isAllowed(OrConstraint.java:51)
at org.drools.rule.OrConstraint.isAllowed(OrConstraint.java)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:143)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
at org.drools.reteoo.EntryPointNode.__AW_assertObject(EntryPointNode.java:146)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046)
at org.drools.common.AbstractWorkingMemory.__AW_insert(AbstractWorkingMemory.java:1001)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788)
at
org.drools.impl.StatelessKnowledgeSessionImpl.__AW_execute(StatelessKnowledgeSessionImpl.java:259)
at
org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java)
I checked out the code and found that when soundex can not parse a string it returns
null.
I think this could be avoided by doing the Soundex.soundex(String) and checking for null
before calling equals.
I'll try to submit a patch if I have the time.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira