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

copilot-swe-agent[bot]
2 days ago 4ea22f76016a4ec21f6b46a2144629de4adeb026
Fix server crash when File-Based Debug Logger is enabled

When the debug logger is enabled, LoggerConfigManager sets root JUL level
to FINEST which makes Grizzly's DefaultFilterChain.executeFilter() check
isLoggable(FINEST)=true and log the FilterChainContext object.

In Grizzly 3.0.1, FilterChainContext.toString() has a bytecode bug where
it does a checkcast to char[] on the message field. When the message is
a LdapResponseMessage, the cast fails with ClassCastException that
propagates through the RxJava pipeline causing a server crash.

Fix: Limit org.glassfish.grizzly JUL logging to FINE level so that
isLoggable(FINEST) returns false, preventing the broken code path.

Also add toString() to LdapResponseMessage for better diagnostics.

Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenDJ/sessions/73a4bf17-653a-4ea6-b379-6a220c9059db

Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
2 files modified
14 ■■■■■ changed files
opendj-core/src/main/java/org/forgerock/opendj/ldap/spi/LdapMessages.java 7 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/core/LoggerConfigManager.java 7 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/spi/LdapMessages.java
@@ -106,6 +106,13 @@
        private LdapResponseMessage(final byte messageType, final int messageId, final Response content) {
            super(messageType, messageId, content);
        }
        @Override
        public String toString() {
            return "LdapResponseMessage(messageType=" + getMessageType()
                    + ", messageId=" + getMessageId()
                    + ", content=" + getContent() + ")";
        }
    }
    private static abstract class LdapMessageEnvelope<T> {
opendj-server-legacy/src/main/java/org/opends/server/core/LoggerConfigManager.java
@@ -109,8 +109,13 @@
      {
        SLF4JBridgeHandler.removeHandlersForRootLogger();
        // This is needed to avoid major performance issue. See: http://www.slf4j.org/legacy.html#jul-to-slf4j
        // Limit Grizzly JUL logging to FINE to prevent a ClassCastException in
        // FilterChainContext.toString() (Grizzly bug) when debug logging is enabled.
        // Grizzly 3.0.1 DefaultFilterChain.executeFilter() checks isLoggable(FINEST) but
        // its FilterChainContext.toString() incorrectly casts the message to char[].
        LogManager.getLogManager().readConfiguration(
                new ByteArrayInputStream((".level=" + newLevel).getBytes()));
                new ByteArrayInputStream(
                        (".level=" + newLevel + "\norg.glassfish.grizzly.level=FINE").getBytes()));
        SLF4JBridgeHandler.install();
        currentJulLogLevel = newLevel;
      }