[jitsi-dev] Fwd: [ice4j] r363 committed - Fixes a failure to close a Socket.


#1

Google has announced the end of google voice, which was the only remaining
use of their ICE variants, so there's not much point in maintaining these
any more.

--sent from my mobile

···

---------- Forwarded message ----------
From: <ice4j@googlecode.com>
Date: 13 Nov 2013 22:44
Subject: [ice4j] r363 committed - Fixes a failure to close a Socket.
To: <ice4j-commits@jitsi.org>
Cc:

Revision: 363
Author: lubomir.marinov@gmail.com
Date: Wed Nov 13 21:44:08 2013 UTC
Log: Fixes a failure to close a Socket.
http://code.google.com/p/ice4j/source/detail?r=363

Modified:
/trunk/src/org/ice4j/ice/harvest/GoogleTurnSSLCandidateHarvester.java

=======================================
--- /trunk/src/org/ice4j/ice/harvest/GoogleTurnSSLCandidateHarvester.java
    Fri Aug 10 13:34:49 2012 UTC
+++ /trunk/src/org/ice4j/ice/harvest/GoogleTurnSSLCandidateHarvester.java
    Wed Nov 13 21:44:08 2013 UTC
@@ -126,32 +126,54 @@
     protected HostCandidate getHostCandidate(HostCandidate hostCand)
     {
         HostCandidate cand = null;
+ Socket sock = null;

         try
         {
- Socket sock = new Socket(stunServer.getAddress(),
- stunServer.getPort());
+ sock = new Socket(stunServer.getAddress(),
stunServer.getPort());

             OutputStream outputStream = sock.getOutputStream();
             InputStream inputStream = sock.getInputStream();

             if(sslHandshake(inputStream, outputStream))
             {
- cand = new HostCandidate(new IceTcpSocketWrapper(
- new MultiplexingSocket(sock)),
- hostCand.getParentComponent(), Transport.TCP);
- hostCand.getParentComponent().getParentStream().
- getParentAgent().getStunStack().addSocket(
- cand.getStunSocket(null));
+ Component parentComponent = hostCand.getParentComponent();
+
+ cand
+ = new HostCandidate(
+ new IceTcpSocketWrapper(
+ new MultiplexingSocket(sock)),
+ parentComponent,
+ Transport.TCP);
+ parentComponent
+ .getParentStream()
+ .getParentAgent()
+ .getStunStack()
+ .addSocket(cand.getStunSocket(null));
             }
- else
- return null;
         }
- catch(Exception io)
+ catch (Exception e)
         {
- return null;
+ cand = null;
         }
-
+ finally
+ {
+ if ((cand == null) && (sock != null))
+ {
+ try
+ {
+ sock.close();
+ }
+ catch (IOException ioe)
+ {
+ /*
+ * We failed to close sock but that should not be much
of a
+ * problem because we were not closing it in earlier
+ * revisions.
+ */
+ }
+ }
+ }
         return cand;
     }