pSpaces / jSpace

Programming with Spaces in Java
MIT License
17 stars 12 forks source link

NullPointerException in Tuple class #20

Closed Uabanur closed 6 years ago

Uabanur commented 6 years ago

Occasionally an exception is thrown from an instance of a Tuple when it tries to acces the fields.length in its internal methods. This suggests that the fields variable is null which should not be possible.

Likewise, occasionally a tuple retrieved with the statement:

room.queryp(new ActualField("gamestate"), new FormalField(GameState.class));

will have a first, but no second argument even though the signature clearly states a tuple of length two. This seems like a bug due to concurrent behaviour.

michele-loreti commented 6 years ago

This behaviour is quite strange. Indeed, a Tuple is an immutable object and its content is never changed. Please, can you post extra info? For instance, are you sure that the variable that is assigned with the result of room.queryp above is local (and never concurrently assigned by another thread)? Moreover, are you checking if the result of the instruction above is not null? Note that queryp is a non-blocking operation that may return null if a matching tuple is not available.