showuon commented on code in PR #23005:
URL: https://github.com/apache/kafka/pull/23005#discussion_r3701101750


##########
clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/secured/JaasOptionsUtils.java:
##########
@@ -85,10 +85,14 @@ public boolean shouldCreateSSLSocketFactory(URL url) {
     public SSLSocketFactory createSSLSocketFactory() {
         Map<String, ?> sslClientConfig = getSslClientConfig();
         SslFactory sslFactory = new SslFactory(ConnectionMode.CLIENT);
-        sslFactory.configure(sslClientConfig);
-        SSLSocketFactory socketFactory = ((DefaultSslEngineFactory) 
sslFactory.sslEngineFactory()).sslContext().getSocketFactory();
-        log.debug("Created SSLSocketFactory: {}", sslClientConfig);
-        return socketFactory;
+        try {
+            sslFactory.configure(sslClientConfig);
+            SSLSocketFactory socketFactory = ((DefaultSslEngineFactory) 
sslFactory.sslEngineFactory()).sslContext().getSocketFactory();
+            log.debug("Created SSLSocketFactory: {}", sslClientConfig);
+            return socketFactory;
+        } finally {
+            sslFactory.close();

Review Comment:
   This fix makes sense only if the `sslFactory.close()` never changes. Could 
we at least add a comment in `DefaultSslEngineFactory.close()` to mention it, 
like: 
   ```
   In JaasOptionsUtils.createSSLSocketFactory(), we assume this close method 
doesn't change the returned SSLContext/SSLSocketFactory objects. 
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to