abhilash1in commented on code in PR #2117: URL: https://github.com/apache/zookeeper/pull/2117#discussion_r1518466128
########## zookeeper-server/src/main/java/org/apache/zookeeper/client/FourLetterWordMain.java: ########## @@ -101,14 +123,16 @@ public static String send4LetterWord( : new InetSocketAddress(InetAddress.getByName(null), port); if (secure) { LOG.info("using secure socket"); - try (X509Util x509Util = new ClientX509Util()) { - SSLContext sslContext = x509Util.getDefaultSSLContext(); - SSLSocketFactory socketFactory = sslContext.getSocketFactory(); - SSLSocket sslSock = (SSLSocket) socketFactory.createSocket(); - sslSock.connect(hostaddress, timeout); - sslSock.startHandshake(); - sock = sslSock; + if (sslContext == null) { + try (X509Util x509Util = new ClientX509Util()) { + sslContext = x509Util.getDefaultSSLContext(); + } Review Comment: The "try-with-resources" construct ensures that each resource declared in the try is closed at the end of the statement, which can help prevent resource leaks. In this case, it's ensuring that the X509Util instance is properly closed after use. It doesn't necessarily need a catch clause because it's about managing resources rather than catching and handling exceptions. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@zookeeper.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org