PAX523 opened a new issue, #3214:
URL: https://github.com/apache/logging-log4j2/issues/3214

   ## 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());
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to