Assuming that this part of the API is meant to be used like this:<br><br> List<String> declIds = );<br> for( String declId: activation.getDeclarationIDs( ){<br> Object declVal = activation.getDeclarationValue( declId );<br>
// ...<br> }<br><br>I'm using this during ActivationEvent logging. If, however, a<br>fact is retracted, this code, when executed for an<br>AfterActivationFiredEvent, throws a NPE when declId is a<br>binding for a component of the retracted fact.<br>
<br>The optimum solution would be to not get such useless bindings<br>in the List<String> returned by getDeclarationIDs() which<br>is in AgendaItem.java. I have added the if-statement:<br><br> public List<String> getDeclarationIDs() {<br>
Declaration[] declArray = this.getRule().getDeclarations(); <br> List<String> declarations = new ArrayList<String>();<br> for( Declaration decl : declArray ) {<br> // return only "sound" declaration IDs<br>
if( this.tuple.get( decl ).getObject() != null ){<br> declarations.add( decl.getIdentifier() );<br> }<br> }<br> return Collections.unmodifiableList( declarations );<br> }<br>
<br>This is untested!<br>-W<br><br><br><br>