[
https://issues.apache.org/jira/browse/ZOOKEEPER-1753?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13761004#comment-13761004
]
Flavio Junqueira commented on ZOOKEEPER-1753:
---------------------------------------------
Do we still need this:
{noformat}
sock.close();
br.close();
{noformat}
at the end of the try block if we have the finally block you're introducing?
> ClientCnxn is not properly releasing the resources, which are used to ping
> RwServer
> -----------------------------------------------------------------------------------
>
> Key: ZOOKEEPER-1753
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1753
> Project: ZooKeeper
> Issue Type: Bug
> Components: java client
> Reporter: Rakesh R
> Assignee: Rakesh R
> Fix For: 3.5.0, 3.4.6
>
> Attachments: 0001-ZOOKEEPER-1753-fix-branch-3_4.patch,
> 0001-ZOOKEEPER-1753.patch
>
>
> While pinging to the RwServer, ClientCnxn is opening a socket and using
> BufferedReader. These are not properly closed in finally block and could
> cause leaks on exceptional cases.
> ClientCnxn#pingRwServer()
> {code}
> try {
> Socket sock = new Socket(addr.getHostName(), addr.getPort());
> BufferedReader br = new BufferedReader(
> new InputStreamReader(sock.getInputStream()));
> ......
> 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);
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira