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>
| | |
| | | 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> { |
| | |
| | | { |
| | | 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; |
| | | } |