[jitsi-dev] ice4j / SafeCloseDatagramSocket / NullPointerException


#1

I found this is needed just before the synchronized block in
SafeCloseDatagramSocket.close():

if(inReceiveSyncRoot == null)
          return;

Otherwise, I occasionally see this exception:

W/System.err( 1440): java.lang.NullPointerException
W/System.err( 1440): at
org.ice4j.socket.SafeCloseDatagramSocket.close(SafeCloseDatagramSocket.java:136)
W/System.err( 1440): at
java.net.DatagramSocket.createSocket(DatagramSocket.java:205)
W/System.err( 1440): at
java.net.DatagramSocket.<init>(DatagramSocket.java:104)
W/System.err( 1440): at
org.ice4j.socket.DelegatingDatagramSocket.<init>(DelegatingDatagramSocket.java:98)
W/System.err( 1440): at
org.ice4j.socket.SafeCloseDatagramSocket.<init>(SafeCloseDatagramSocket.java:101)
W/System.err( 1440): at
org.ice4j.socket.MultiplexingDatagramSocket.<init>(MultiplexingDatagramSocket.java:142)
W/System.err( 1440): at
org.ice4j.ice.harvest.HostCandidateHarvester.createDatagramSocket(HostCandidateHarvester.java:334)
W/System.err( 1440): at
org.ice4j.ice.harvest.HostCandidateHarvester.harvest(HostCandidateHarvester.java:99)
W/System.err( 1440): at
org.ice4j.ice.Agent.gatherCandidates(Agent.java:420)
W/System.err( 1440): at org.ice4j.ice.Agent.createComponent(Agent.java:330)


#2

Hi Daniel,

Thank you to have find this.

It is interresting, it seems that DatagramSocket.createSocket() will close the socket directly in the constructor of DatagramSocket which let the member inReceiveSyncRoot unitialized (null) when overrided close method is called.

Regards,

···

--
Seb

Le 12/01/12 03:15, Daniel Pocock a �crit :

I found this is needed just before the synchronized block in
SafeCloseDatagramSocket.close():

if(inReceiveSyncRoot == null)
           return;

Otherwise, I occasionally see this exception:

W/System.err( 1440): java.lang.NullPointerException
W/System.err( 1440): at
org.ice4j.socket.SafeCloseDatagramSocket.close(SafeCloseDatagramSocket.java:136)
W/System.err( 1440): at
java.net.DatagramSocket.createSocket(DatagramSocket.java:205)
W/System.err( 1440): at
java.net.DatagramSocket.<init>(DatagramSocket.java:104)
W/System.err( 1440): at
org.ice4j.socket.DelegatingDatagramSocket.<init>(DelegatingDatagramSocket.java:98)
W/System.err( 1440): at
org.ice4j.socket.SafeCloseDatagramSocket.<init>(SafeCloseDatagramSocket.java:101)
W/System.err( 1440): at
org.ice4j.socket.MultiplexingDatagramSocket.<init>(MultiplexingDatagramSocket.java:142)
W/System.err( 1440): at
org.ice4j.ice.harvest.HostCandidateHarvester.createDatagramSocket(HostCandidateHarvester.java:334)
W/System.err( 1440): at
org.ice4j.ice.harvest.HostCandidateHarvester.harvest(HostCandidateHarvester.java:99)
W/System.err( 1440): at
org.ice4j.ice.Agent.gatherCandidates(Agent.java:420)
W/System.err( 1440): at org.ice4j.ice.Agent.createComponent(Agent.java:330)