[
https://issues.jboss.org/browse/JBRULES-3685?page=com.atlassian.jira.plug...
]
Radai Rosenblatt updated JBRULES-3685:
--------------------------------------
Description:
i have a rule that looks like this:
{code}
rule "bad node status"
when
$ruleIdString1 : [get from somewhere]
$node1 : Node($idString1 : idString)
$hostStatus1 : HostStatus($status1 : status , nodeIdString == $idString1 , status !=
"up") from entry-point "Event Stream"
then
Map alertParams = new HashMap();
alertParams.put("0",($status1));
Map reportParams = null;
Map reportFieldValues = null;
String component = null;
alerts.issueAlert($idString1 , UUID.fromString($ruleIdString1) , alertParams ,
reportParams, reportFieldValues, component);
end
{code}
this causes drools to generate a class by the name of
Rule_Bad_Node_Status_0DefaultConsequenceInvoker.java with the following bit of code:
{code}
public void evaluate(org.drools.spi.KnowledgeHelper knowledgeHelper,
org.drools.WorkingMemory workingMemory) throws Exception {
org.drools.spi.Tuple tuple = knowledgeHelper.getTuple();
org.drools.rule.Declaration[] declarations =
knowledgeHelper.getRule().getDeclarations();
org.drools.common.InternalFactHandle $ruleIdString1__Handle__ = (
org.drools.common.InternalFactHandle ) tuple.get( knowledgeHelper.getDeclaration(
declarations[1].getIdentifier() ) );
java.lang.String $ruleIdString1 = ( java.lang.String )
declarations[1].getValue((org.drools.common.InternalWorkingMemory) workingMemory,
$ruleIdString1__Handle__.getObject() );
$ruleIdString1__Handle__ = (org.drools.common.InternalFactHandle)
knowledgeHelper.getWorkingMemory().getFactHandle( $ruleIdString1 );
knowledgeHelper.getIdentityMap().put($ruleIdString1, $ruleIdString1__Handle__
);
org.drools.common.InternalFactHandle $idString2__Handle__ = (
org.drools.common.InternalFactHandle ) tuple.get( knowledgeHelper.getDeclaration(
declarations[3].getIdentifier() ) );
java.lang.String $idString2 = ( java.lang.String )
declarations[3].getValue((org.drools.common.InternalWorkingMemory) workingMemory,
$idString2__Handle__.getObject() );
$idString2__Handle__ = (org.drools.common.InternalFactHandle)
knowledgeHelper.getWorkingMemory().getFactHandle( $idString2 );
knowledgeHelper.getIdentityMap().put($idString2, $idString2__Handle__ );
org.drools.common.InternalFactHandle $status1__Handle__ = (
org.drools.common.InternalFactHandle ) tuple.get( knowledgeHelper.getDeclaration(
declarations[5].getIdentifier() ) );
java.lang.String $status1 = ( java.lang.String )
declarations[5].getValue((org.drools.common.InternalWorkingMemory) workingMemory,
$status1__Handle__.getObject() );
$status1__Handle__ = (org.drools.common.InternalFactHandle)
knowledgeHelper.getWorkingMemory().getFactHandle( $status1 ); //NullPointerException
here
knowledgeHelper.getIdentityMap().put($status1, $status1__Handle__ );
com.emc.dpa.analysis.Alerts alerts = ( com.emc.dpa.analysis.Alerts )
workingMemory.getGlobal( "alerts" );
Rule_Bad_Node_Status_0.defaultConsequence (
knowledgeHelper,
$ruleIdString1, $ruleIdString1__Handle__
, $idString2, $idString2__Handle__
, $status1, $status1__Handle__
,
alerts
);
}
{code}
if, for some reason, the value for HostStatus.status is null i get a NPE from the
commented line in the above code. the stack trace looks like this:
{code}
Caused by: java.lang.NullPointerException
at
org.drools.common.EqualityAssertMapComparator.hashCodeOf(EqualityAssertMapComparator.java:48)
[drools-core.jar:5.1.1]
at org.drools.core.util.ObjectHashMap.get(ObjectHashMap.java:100)
[drools-core.jar:5.1.1]
at
org.drools.common.SingleThreadedObjectStore.getHandleForObject(SingleThreadedObjectStore.java:122)
[drools-core.jar:5.1.1]
at org.drools.common.AbstractWorkingMemory.getFactHandle(AbstractWorkingMemory.java:861)
[drools-core.jar:5.1.1]
at
[package].Rule_Bad_Node_Status_0DefaultConsequenceInvoker.evaluate(Rule_Bad_Node_Status_0DefaultConsequenceInvoker.java:33)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917)
[drools-core.jar:5.1.1]
... 101 more
{code}
i think this is related to the line in the then section that reads
"alertParams.put("0",($status1));" but i think putting null into a map
should be possible.
was:
i have a rule that looks like this:
{code}
rule "bad node status"
when
$ruleIdString1 : [get from somewhere]
$node1 : Node($idString1 : idString)
$hostStatus1 : HostStatus($status1 : status , nodeIdString == $idString1 , status !=
"up") from entry-point "Event Stream"
then
Map alertParams = new HashMap();
alertParams.put("0",($status1));
Map reportParams = null;
Map reportFieldValues = null;
String component = null;
alerts.issueAlert($idString1 , UUID.fromString($ruleIdString1) , alertParams ,
reportParams, reportFieldValues, component);
end
{code}
this causes drools to generate a class by the name of
Rule_Bad_Node_Status_0DefaultConsequenceInvoker.java with the following bit of code:
{code}
public void evaluate(org.drools.spi.KnowledgeHelper knowledgeHelper,
org.drools.WorkingMemory workingMemory) throws Exception {
org.drools.spi.Tuple tuple = knowledgeHelper.getTuple();
org.drools.rule.Declaration[] declarations =
knowledgeHelper.getRule().getDeclarations();
org.drools.common.InternalFactHandle $ruleIdString1__Handle__ = (
org.drools.common.InternalFactHandle ) tuple.get( knowledgeHelper.getDeclaration(
declarations[1].getIdentifier() ) );
java.lang.String $ruleIdString1 = ( java.lang.String )
declarations[1].getValue((org.drools.common.InternalWorkingMemory) workingMemory,
$ruleIdString1__Handle__.getObject() );
$ruleIdString1__Handle__ = (org.drools.common.InternalFactHandle)
knowledgeHelper.getWorkingMemory().getFactHandle( $ruleIdString1 );
knowledgeHelper.getIdentityMap().put($ruleIdString1, $ruleIdString1__Handle__
);
org.drools.common.InternalFactHandle $idString2__Handle__ = (
org.drools.common.InternalFactHandle ) tuple.get( knowledgeHelper.getDeclaration(
declarations[3].getIdentifier() ) );
java.lang.String $idString2 = ( java.lang.String )
declarations[3].getValue((org.drools.common.InternalWorkingMemory) workingMemory,
$idString2__Handle__.getObject() );
$idString2__Handle__ = (org.drools.common.InternalFactHandle)
knowledgeHelper.getWorkingMemory().getFactHandle( $idString2 );
knowledgeHelper.getIdentityMap().put($idString2, $idString2__Handle__ );
org.drools.common.InternalFactHandle $status1__Handle__ = (
org.drools.common.InternalFactHandle ) tuple.get( knowledgeHelper.getDeclaration(
declarations[5].getIdentifier() ) );
java.lang.String $status1 = ( java.lang.String )
declarations[5].getValue((org.drools.common.InternalWorkingMemory) workingMemory,
$status1__Handle__.getObject() );
$status1__Handle__ = (org.drools.common.InternalFactHandle)
knowledgeHelper.getWorkingMemory().getFactHandle( $status1 ); //NullPointerException
here
knowledgeHelper.getIdentityMap().put($status1, $status1__Handle__ );
com.emc.dpa.analysis.Alerts alerts = ( com.emc.dpa.analysis.Alerts )
workingMemory.getGlobal( "alerts" );
Rule_Bad_Node_Status_0.defaultConsequence (
knowledgeHelper,
$ruleIdString1, $ruleIdString1__Handle__
, $idString2, $idString2__Handle__
, $status1, $status1__Handle__
,
alerts
);
}
{code}
if, for some reason, the value for HostStatus is null i get a NPE from the commented line
in the above code. the stack trace looks like this:
{code}
Caused by: java.lang.NullPointerException
at
org.drools.common.EqualityAssertMapComparator.hashCodeOf(EqualityAssertMapComparator.java:48)
[drools-core.jar:5.1.1]
at org.drools.core.util.ObjectHashMap.get(ObjectHashMap.java:100)
[drools-core.jar:5.1.1]
at
org.drools.common.SingleThreadedObjectStore.getHandleForObject(SingleThreadedObjectStore.java:122)
[drools-core.jar:5.1.1]
at org.drools.common.AbstractWorkingMemory.getFactHandle(AbstractWorkingMemory.java:861)
[drools-core.jar:5.1.1]
at
[package].Rule_Bad_Node_Status_0DefaultConsequenceInvoker.evaluate(Rule_Bad_Node_Status_0DefaultConsequenceInvoker.java:33)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917)
[drools-core.jar:5.1.1]
... 101 more
{code}
im guessing this is somehow related to my line in the then section taht reads
NullPointerException in DefaultConsequenceInvoker at evaluate()
---------------------------------------------------------------
Key: JBRULES-3685
URL:
https://issues.jboss.org/browse/JBRULES-3685
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: drools-core (expert)
Affects Versions: 5.1.1.FINAL
Environment: java 6, windows 7 x64
Reporter: Radai Rosenblatt
Assignee: Mark Proctor
i have a rule that looks like this:
{code}
rule "bad node status"
when
$ruleIdString1 : [get from somewhere]
$node1 : Node($idString1 : idString)
$hostStatus1 : HostStatus($status1 : status , nodeIdString == $idString1 , status !=
"up") from entry-point "Event Stream"
then
Map alertParams = new HashMap();
alertParams.put("0",($status1));
Map reportParams = null;
Map reportFieldValues = null;
String component = null;
alerts.issueAlert($idString1 , UUID.fromString($ruleIdString1) , alertParams ,
reportParams, reportFieldValues, component);
end
{code}
this causes drools to generate a class by the name of
Rule_Bad_Node_Status_0DefaultConsequenceInvoker.java with the following bit of code:
{code}
public void evaluate(org.drools.spi.KnowledgeHelper knowledgeHelper,
org.drools.WorkingMemory workingMemory) throws Exception {
org.drools.spi.Tuple tuple = knowledgeHelper.getTuple();
org.drools.rule.Declaration[] declarations =
knowledgeHelper.getRule().getDeclarations();
org.drools.common.InternalFactHandle $ruleIdString1__Handle__ = (
org.drools.common.InternalFactHandle ) tuple.get( knowledgeHelper.getDeclaration(
declarations[1].getIdentifier() ) );
java.lang.String $ruleIdString1 = ( java.lang.String )
declarations[1].getValue((org.drools.common.InternalWorkingMemory) workingMemory,
$ruleIdString1__Handle__.getObject() );
$ruleIdString1__Handle__ = (org.drools.common.InternalFactHandle)
knowledgeHelper.getWorkingMemory().getFactHandle( $ruleIdString1 );
knowledgeHelper.getIdentityMap().put($ruleIdString1, $ruleIdString1__Handle__
);
org.drools.common.InternalFactHandle $idString2__Handle__ = (
org.drools.common.InternalFactHandle ) tuple.get( knowledgeHelper.getDeclaration(
declarations[3].getIdentifier() ) );
java.lang.String $idString2 = ( java.lang.String )
declarations[3].getValue((org.drools.common.InternalWorkingMemory) workingMemory,
$idString2__Handle__.getObject() );
$idString2__Handle__ = (org.drools.common.InternalFactHandle)
knowledgeHelper.getWorkingMemory().getFactHandle( $idString2 );
knowledgeHelper.getIdentityMap().put($idString2, $idString2__Handle__ );
org.drools.common.InternalFactHandle $status1__Handle__ = (
org.drools.common.InternalFactHandle ) tuple.get( knowledgeHelper.getDeclaration(
declarations[5].getIdentifier() ) );
java.lang.String $status1 = ( java.lang.String )
declarations[5].getValue((org.drools.common.InternalWorkingMemory) workingMemory,
$status1__Handle__.getObject() );
$status1__Handle__ = (org.drools.common.InternalFactHandle)
knowledgeHelper.getWorkingMemory().getFactHandle( $status1 ); //NullPointerException
here
knowledgeHelper.getIdentityMap().put($status1, $status1__Handle__ );
com.emc.dpa.analysis.Alerts alerts = ( com.emc.dpa.analysis.Alerts )
workingMemory.getGlobal( "alerts" );
Rule_Bad_Node_Status_0.defaultConsequence (
knowledgeHelper,
$ruleIdString1, $ruleIdString1__Handle__
, $idString2, $idString2__Handle__
, $status1, $status1__Handle__
,
alerts
);
}
{code}
if, for some reason, the value for HostStatus.status is null i get a NPE from the
commented line in the above code. the stack trace looks like this:
{code}
Caused by: java.lang.NullPointerException
at
org.drools.common.EqualityAssertMapComparator.hashCodeOf(EqualityAssertMapComparator.java:48)
[drools-core.jar:5.1.1]
at org.drools.core.util.ObjectHashMap.get(ObjectHashMap.java:100)
[drools-core.jar:5.1.1]
at
org.drools.common.SingleThreadedObjectStore.getHandleForObject(SingleThreadedObjectStore.java:122)
[drools-core.jar:5.1.1]
at org.drools.common.AbstractWorkingMemory.getFactHandle(AbstractWorkingMemory.java:861)
[drools-core.jar:5.1.1]
at
[package].Rule_Bad_Node_Status_0DefaultConsequenceInvoker.evaluate(Rule_Bad_Node_Status_0DefaultConsequenceInvoker.java:33)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917)
[drools-core.jar:5.1.1]
... 101 more
{code}
i think this is related to the line in the then section that reads
"alertParams.put("0",($status1));" but i think putting null into a map
should be possible.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira