Version 1.11.1 of SNMP4J included a fix for a race condition in  
DefautlUdpTrasnportMapping which caused a NullPointerException.   
However, there is still one that remains while attempting to read a  
packet and I see this from time to time.  Below is a patch that fixes  
the problem for me that I'd like to submit for review.

Index: src/org/snmp4j/transport/DefaultUdpTransportMapping.java
===================================================================
--- src/org/snmp4j/transport/DefaultUdpTransportMapping.java    (revision  
215)
+++ src/org/snmp4j/transport/DefaultUdpTransportMapping.java    (working  
copy)
@@ -337,7 +337,11 @@
                                                      
udpAddress.getPort());
          try {
            try {
-            socket.receive(packet);
+            DatagramSocket readingSocket = socket;
+            if (readingSocket == null) {
+              continue;
+            }
+            readingSocket.receive(packet);
            }
            catch (InterruptedIOException iiox) {
              if (iiox.bytesTransferred <= 0) {

_______________________________________________
SNMP4J mailing list
[email protected]
http://lists.agentpp.org/mailman/listinfo/snmp4j

Reply via email to