On Wed, 17 Jun 2026 00:48:30 GMT, Ashay Rane <[email protected]> wrote:

> Instead of discarding the newly created `CommunicationException`
> exception and referencing the outer (caught)
> `SSLPeerUnverifiedException` exception, this patch adds the
> `SSLPeerUnverifiedException` exception as the suppressed exception of
> the newly created `CommunicationException` exception.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java line 1177:

> 1175:                 CommunicationException ce = new 
> CommunicationException();
> 1176:                 ce.setRootCause(closureReason);
> 1177:                 ce.addSuppressed(ex);

Hello Ashay, I think this will need a slightly different change. The 
`closureReason` may be null, so it might be better to do something like (this 
untested change):


diff --git a/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java 
b/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java
--- a/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java
+++ b/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java
@@ -1173,8 +1173,14 @@ public void handshakeCompleted(HandshakeCompletedEvent 
event) {
                 tlsHandshakeCompleted.complete(tlsServerCert);
             } catch (SSLPeerUnverifiedException ex) {
                 CommunicationException ce = new CommunicationException();
-                ce.setRootCause(closureReason);
-                tlsHandshakeCompleted.completeExceptionally(ex);
+                IOException priorFailure = closureReason;
+                if (priorFailure != null) {
+                    ce.setRootCause(priorFailure);
+                    ce.addSuppressed(ex);
+                } else {
+                    ce.setRootCause(ex);
+                }
+                tlsHandshakeCompleted.completeExceptionally(ce);
             }
         }
     }

The tests for this area reside in `tier2`. So please also run tier2 locally to 
make sure nothing fails due to this change.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/31545#discussion_r3428607576

Reply via email to