-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
bugIncorrect, unexpected, or unintended behavior of existing codeIncorrect, unexpected, or unintended behavior of existing codewaiting-for-maintainer
Milestone
Description
Description
It occurs depending on the Java version and the used JVM implementation. We're migrating from Java 8 to Java 17. I cannot reproduce it with Oracle JDK 8, but with OpenJ9 JDK 8. The problem is that there are threads with an empty stacktrace which is not expected by ExtendedThreadInformation.
Configuration
Version: 2.17.2
Operating system: N/A
JDK: 17.0.3_7_openj9
Logs
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
at org.apache.logging.log4j.core.message.ExtendedThreadInformation.formatState(ExtendedThreadInformation.java:141)
at org.apache.logging.log4j.core.message.ExtendedThreadInformation.printThreadInfo(ExtendedThreadInformation.java:44)
at org.apache.logging.log4j.message.ThreadDumpMessage.formatTo(ThreadDumpMessage.java:98)
at org.apache.logging.log4j.message.ThreadDumpMessage.getFormattedMessage(ThreadDumpMessage.java:86)
at de.icongmbh.dopix.logging.log4j.TestLog4jLogManager.dumpAllThreads_loggerIsEnabled_generateLogEvent(TestLog4jLogManager.java:293)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
Reproduction
ExtendedLogger loggerLogger = mock(ExtendedLogger.class, "loggerLogger");
when(this.contextResolver.get()).thenReturn(this.context);
when(this.context.getLogger(Log4jLogManager.class.getName())).thenReturn(this.loggerLogger);
when(this.configFactory.create(any(LoggerContext.class))).thenReturn(this.config);
this.subjectUnderTest = new Log4jLogManager(this.contextResolver, this.configFactory);
verify(this.configFactory, atLeastOnce()).create(this.context);
when(this.context.getLogger(LOGGER_NAME)).thenReturn(this.logger);
when(this.loggerLogger.isEnabled(isA(Level.class), isA(Marker.class))).thenReturn(true);
assertThat(this.subjectUnderTest.dumpAllThreads(CATEGORIES_MASK)).isTrue();
final ArgumentCaptor<Message> message = ArgumentCaptor.forClass(Message.class);
verify(this.loggerLogger).logMessage(eq(RESULTING_LEVEL),
eq(RESULTING_MARKER),
eq(Log4jLogManager.FQCN),
any(StackTraceElement.class),
message.capture(),
ArgumentMatchers.<Throwable> isNull());
assertThat(message.getValue().getFormattedMessage()).contains(Thread.currentThread().getName());
Metadata
Metadata
Assignees
Labels
bugIncorrect, unexpected, or unintended behavior of existing codeIncorrect, unexpected, or unintended behavior of existing codewaiting-for-maintainer
Type
Projects
Status
Done