[SNMP4J] Another race condition fix for DefaultUdpTransportMapping

Frank Fock fock at agentpp.com
Fri Sep 24 01:24:22 CEST 2010


Hi Paul,

Thank you for the bug report. If fixed it a bit different:

           try {
             DatagramSocket socketCopy = socket;
             if (socketCopy == null) {
               stop = true;
               continue;
             }
             socketCopy.receive(packet);
           }

Best regards,
Frank

On 23.09.2010 23:44, Paul Marquis wrote:
> 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
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j

-- 
AGENT++
http://www.agentpp.com
http://www.snmp4j.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the SNMP4J mailing list