mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
26.44.2013 1f2f46fa65db97b476f588e9f92d19d447b1b6ea
Minor code cleanup for OPENDJ-672: LDAP SDK SSL connect attempts fail with horrible stack trace when handshake fails

* make the connection close logic more tolerant of underlying Grizzly behavior, although the bug is unreproducible with the latest SDK + Grizzly 2.3.4.
1 files modified
18 ■■■■■ changed files
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPConnection.java 18 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPConnection.java
@@ -623,21 +623,23 @@
            }
        }
        // Now try cleanly closing the connection if possible.
        // Only send unbind if specified.
        /*
         * Now try cleanly closing the connection if possible. Only send unbind
         * if specified.
         */
        if (unbindRequest != null) {
            try {
                final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
                try {
                    ldapWriter
                            .unbindRequest(asn1Writer, nextMsgID.getAndIncrement(), unbindRequest);
                ldapWriter.unbindRequest(asn1Writer, nextMsgID.getAndIncrement(), unbindRequest);
                    connection.write(asn1Writer.getBuffer(), null);
            } catch (final Exception ignore) {
                /*
                 * Underlying channel probably blown up. Ignore all errors,
                 * including possibly runtime exceptions (see OPENDJ-672).
                 */
                } finally {
                    asn1Writer.recycle();
                }
            } catch (final IOException e) {
                // Underlying channel prob blown up. Just ignore.
            }
        }
        factory.getTimeoutChecker().removeConnection(this);
        connection.closeSilently();