[jboss-jira] [JBoss JIRA] (JBRULES-2621) NPE due to activation.getDeclarationValue( declId )

Geoffrey De Smet (Updated) (JIRA) jira-events at lists.jboss.org
Tue Dec 20 05:15:39 EST 2011


     [ https://issues.jboss.org/browse/JBRULES-2621?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Geoffrey De Smet updated JBRULES-2621:
--------------------------------------

    Fix Version/s: 5.4.0.Beta2
                       (was: 5.4.0.Beta1)

    
> NPE due to activation.getDeclarationValue( declId )
> ---------------------------------------------------
>
>                 Key: JBRULES-2621
>                 URL: https://issues.jboss.org/browse/JBRULES-2621
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-api
>    Affects Versions: 5.1.0.FINAL
>            Reporter: Wolfgang Laun
>            Assignee: Edson Tirelli
>             Fix For: 5.4.0.Beta2
>
>
> Trying to access the declarations and their values of an activation, as used during ActivationEvent logging:
>    List<String> declIds = );
>    for( String declId: activation.getDeclarationIDs( ){
>       Object declVal = activation.getDeclarationValue( declId );
>       // ...
>    }
> If, however, a fact is retracted, this code, when executed for an AfterActivationFiredEvent, throws a NPE when declId is a binding for a component of the retracted fact.
> The optimum solution would be to not get such useless bindings in the List<String> returned by getDeclarationIDs() which is in AgendaItem.java. I have added the if-statement. The following code is untested:
>     public List<String> getDeclarationIDs() {
>         Declaration[] declArray = this.getRule().getDeclarations();
>         List<String> declarations = new ArrayList<String>();
>         for( Declaration decl : declArray ) {
>             // return only "sound" declaration IDs
>             if( this.tuple.get( decl ).getObject() != null ){
>                 declarations.add( decl.getIdentifier() );
>             }
>         }
>         return Collections.unmodifiableList( declarations );
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list