[SNMP4J] Exception when closing snmp on 1.7RC1
Frank Fock
fock at agentpp.com
Fri Mar 10 19:47:36 CET 2006
Hi Matthieu,
The following code should improve the behavior:
/**
* Closes the socket and stops the listener thread.
*
* @throws IOException
*/
public void close() throws IOException {
ListenThread l = listener;
if (l != null) {
l.close();
l.interrupt();
if (socketTimeout > 0) {
try {
l.join();
}
catch (InterruptedException ex) {
logger.warn(ex);
}
}
listener = null;
}
if (!socket.isClosed()) {
socket.close();
}
}
Best regards,
Frank
Matthieu Casanova wrote:
> Hi, I closed my snmp object and got this exception
>
> java.lang.NullPointerException
> at org.snmp4j.transport.DefaultUdpTransportMapping.close(
> DefaultUdpTransportMapping.java:93)
> at org.snmp4j.Snmp.close(Snmp.java:428)
>
> I'm not sure but maybe during DefaultUdpTransportMapping.close, just after
> the test
> if (listener != null)
>
> the run method finished and put listener = null (this listener = null; was
> added in 1.7rc1) breaking the close method.
> So is it a bug or is it because I forgot something ?
>
> Matthieu
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
--
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com
More information about the SNMP4J
mailing list