[SNMP4J] ConcurrentModificationException on close()
Paul Donohue
snmp4j at TopQuark.net
Fri Mar 21 15:09:54 CET 2008
I'm regularly seeing a java.util.ConcurrentModificationException when I call close() from my ResponseListener. It appears to happen on occasion in all three of my calls to close() (after a timeout, after an error, and even after processing a valid response):
ResponseListener listener = new ResponseListener() {
public void onResponse(ResponseEvent event) {
// Always cancel async request when response has been received
// otherwise a memory leak is created! Not canceling a request
// immediately can be useful when sending a request to a broadcast
// address.
((Snmp)event.getSource()).cancel(event.getRequest(), this);
if (event.getError() instanceof InterruptedException) {
System.out.println("Interrupted: "+event.getError());
} else if (event.getResponse() == null) {
System.out.println("Timeout");
((Snmp)event.getSource()).close();
} else if (event.getError() != null) {
System.out.println("Error: "+event.getError());
((Snmp)event.getSource()).close();
} else {
System.out.println("Received response PDU is: "+event.getResponse());
((Snmp)event.getSource()).close();
}
}
};
[...]
Timeout
java.util.ConcurrentModificationException
at java.util.Hashtable$Enumerator.next(Hashtable.java:1031)
at org.snmp4j.Snmp.close(Unknown Source)
[...]
I see 3 possibly related reports on this mailing list of similar problems, but I don't see any relevant replies to them:
http://lists.agentpp.org/pipermail/snmp4j/2006-February/001039.html
http://lists.agentpp.org/pipermail/snmp4j/2006-October/001722.html
http://lists.agentpp.org/pipermail/snmp4j/2007-July/002362.html
Any suggestions for correcting this?
Should I skip the cancel() call when there is an InterruptedException? If so, are there any other situations where I should skip the cancel() call?
Let me know if I can provide any additional information.
Thanks!
-Paul
More information about the SNMP4J
mailing list