zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f..@apache.org
Subject svn commit: r1524387 - in /zookeeper/branches/branch-3.4: CHANGES.txt src/java/main/org/apache/zookeeper/ClientCnxn.java
Date Wed, 18 Sep 2013 12:33:46 GMT
Author: fpj
Date: Wed Sep 18 12:33:45 2013
New Revision: 1524387

URL: http://svn.apache.org/r1524387
Log:
ZOOKEEPER-1753. ClientCnxn is not properly releasing the resources, which are used to ping
RwServer (Rakesh R via fpj)


Modified:
    zookeeper/branches/branch-3.4/CHANGES.txt
    zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ClientCnxn.java

Modified: zookeeper/branches/branch-3.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/CHANGES.txt?rev=1524387&r1=1524386&r2=1524387&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.4/CHANGES.txt Wed Sep 18 12:33:45 2013
@@ -104,6 +104,9 @@ BUGFIXES:
 
   ZOOKEEPER-1657. Increased CPU usage by unnecessary SASL checks (Philip K. Warren via fpj)
 
+  ZOOKEEPER-1753. ClientCnxn is not properly releasing the resources, 
+                  which are used to ping RwServer (Rakesh R via fpj)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1564. Allow JUnit test build with IBM Java

Modified: zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ClientCnxn.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ClientCnxn.java?rev=1524387&r1=1524386&r2=1524387&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ClientCnxn.java (original)
+++ zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ClientCnxn.java Wed Sep
18 12:33:45 2013
@@ -1128,25 +1128,40 @@ public class ClientCnxn {
             LOG.info("Checking server " + addr + " for being r/w." +
                     " Timeout " + pingRwTimeout);
 
+            Socket sock = null;
+            BufferedReader br = null;
             try {
-                Socket sock = new Socket(addr.getHostName(), addr.getPort());
+                sock = new Socket(addr.getHostName(), addr.getPort());
                 sock.setSoLinger(false, -1);
                 sock.setSoTimeout(1000);
                 sock.setTcpNoDelay(true);
                 sock.getOutputStream().write("isro".getBytes());
                 sock.getOutputStream().flush();
                 sock.shutdownOutput();
-                BufferedReader br = new BufferedReader(
+                br = new BufferedReader(
                         new InputStreamReader(sock.getInputStream()));
                 result = br.readLine();
-                sock.close();
-                br.close();
             } catch (ConnectException e) {
                 // ignore, this just means server is not up
             } catch (IOException e) {
                 // some unexpected error, warn about it
                 LOG.warn("Exception while seeking for r/w server " +
                         e.getMessage(), e);
+            } finally {
+                if (sock != null) {
+                    try {
+                        sock.close();
+                    } catch (IOException e) {
+                        LOG.warn("Unexpected exception", e);
+                    }
+                }
+                if (br != null) {
+                    try {
+                        br.close();
+                    } catch (IOException e) {
+                        LOG.warn("Unexpected exception", e);
+                    }
+                }
             }
 
             if ("rw".equals(result)) {



Mime
View raw message