Assuming that this part of the API is meant to be used like this:
List<String> declIds = );
for( String declId: activation.getDeclarationIDs( ){
Object declVal = activation.getDeclarationValue( declId );
// ...
}
I'm using this during ActivationEvent logging. 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:
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 is untested!
-W
Show replies by date