I thought Java had short circuit evaluation, yet this line is still throwing a null pointer exception:
if( (perfectAgent != null) && (perfectAgent.ge
Java does have short circuit evaluation. Perhaps entry is null and so entry.getKey() is causing the NullPointerException. Another possibility is that getAddress() either returns null or has a NullPointerException happening inside somewhere (if it's more complicated than a simple return statement).
EDIT: I see your edit where you claim this:
More to the point, it is impossible to execute
perfectAgent.getAddress()...
But what if perfectAgent.getAddress() is successfully executed and returns null? See what I mean...