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

Code before:
                    if (OpenSsl.isBoringSSL() && clientMode) {
                        // If in client-mode and BoringSSL 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);
        }
        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;
    }

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

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

Review comment (suggestion):
```suggestion
            PlatformDependent.throwException(cause);
```

Code after:
                    if (OpenSsl.isBoringSSL() && clientMode) {
                        // If in client-mode and BoringSSL 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);
        }
        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;
    }

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

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