On Thu, 11 Jun 2026 18:45:06 GMT, Ashay Rane <[email protected]> wrote:
> Every time an exception object is created, the constructor calls > `fillInStackTrace()`, which has to walk the call stack to record every > frame. This is expensive, and it's also unnecessary if the exception is > never thrown. There are a few instances in various parts of the JDK > libraries where we create an exception in the dominator block but don't > always throw it. This patch fixes those cases so that if the exception > is not going to be thrown, it is never created in the first place. > > --------- > - [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 1178: > 1176: ce.setRootCause(closureReason); > 1177: tlsHandshakeCompleted.completeExceptionally(ce); > 1178: } This should probably include the `SSLPeerUnverifiedException` as a suppressed exception of the `CommunicationException`: Suggestion: } catch (SSLPeerUnverifiedException ex) { CommunicationException ce = new CommunicationException(); ce.setRootCause(closureReason); ce.addSuppressed(ex); tlsHandshakeCompleted.completeExceptionally(ce); } ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/31487#discussion_r3402386799
