Repository: netty/netty
File: handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java (Java)

Code before:
                    SSL.setRenegotiateMode(ssl, SSL.SSL_RENEGOTIATE_ONCE);
                }
                // setMode may impact the overhead.
                calculateMaxWrapOverhead();

                // Configure any endpoint verification specified by the SslContext.
                configureEndpointVerification(endpointIdentificationAlgorithm);
            } catch (Throwable cause) {
                // Call shutdown so we are sure we correctly release all native memory and also guard against the
                // case when shutdown() will be called by the finalizer again.
                shutdown();

                PlatformDependent.throwException(cause);
            }
        }

        // Now that everything looks good and we're going to successfully return the
        // object so we need to retain a reference to the parent context.
        parentContext = context;
        parentContext.retain();

        // Only create the leak after everything else was executed and so ensure we don't produce a false-positive for
        // the ResourceLeakDetector.
        leak = leakDetection ? leakDetector.track(this) : null;
    }

    private static boolean isValidHostNameForSNI(String hostname) {
        try {
            new SNIHostName(hostname);
            return true;
        } catch (IllegalArgumentException illegal) {
            return false;
        }
    }

    final synchronized String[] authMethods() {
        if (destroyed) {
            return EMPTY_STRINGS;
        }
        return SSL.authenticationMethods(ssl);
    }

    final void setKeyMaterial(OpenSslKeyMaterial keyMaterial) throws  Exception {
        synchronized (this) {
            if (destroyed) {
                return;
            }
            SSL.setKeyMaterial(ssl, keyMaterial.certificateChainAddress(), keyMaterial.privateKeyAddress());
        }
        session.setLocalCertificate(keyMaterial.certificateChain());
    }

Review comment (suggestion):
```suggestion
            throw cause;
```

Pretty sure java is smart enough to figure out that this doesn't need an extra exception declaration.

Code after:

                    if ((OpenSsl.isBoringSSL() || OpenSsl.isAWSLC()) && clientMode) {
                        // If in client-mode and provider is BoringSSL or AWS-LC let's allow to renegotiate once as the
                        // server may use this for client auth.
                        //
                        // See https://github.com/netty/netty/issues/11529
                        SSL.setRenegotiateMode(ssl, SSL.SSL_RENEGOTIATE_ONCE);
                    }
                    // setMode may impact the overhead.
                    calculateMaxWrapOverhead();

                    // Configure any endpoint verification specified by the SslContext.
                    configureEndpointVerification(endpointIdentificationAlgorithm);
                } catch (Throwable cause) {
                    // Call shutdown so we are sure we correctly release all native memory and also guard against the
                    // case when shutdown() will be called by the finalizer again.
                    shutdown();

                    PlatformDependent.throwException(cause);
                }
            }
        } catch (Throwable cause) {
            // Something did go wrong which means we will not be able to release the context later on. Release it
            // now to prevent leaks.
            context.release();
            PlatformDependent.throwException(cause);
        }

        // Now that everything looks good and we're going to successfully return the
        // object so we need to retain a reference to the parent context.
        parentContext = context;

        // Only create the leak after everything else was executed and so ensure we don't produce a false-positive for
        // the ResourceLeakDetector.
        leak = leakDetection ? leakDetector.track(this) : null;
    }

    private static boolean isValidHostNameForSNI(String hostname) {
        try {
            new SNIHostName(hostname);
            return true;
        } catch (IllegalArgumentException illegal) {
            return false;
        }
    }

    final synchronized String[] authMethods() {
        if (destroyed) {
            return EMPTY_STRINGS;
        }
        return SSL.authenticationMethods(ssl);