-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Handle missing stack traces in ExtendedThreadInformation #3655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PAX523, thanks so much for the fix! It is a pleasure to collaborate with an external contributor knowing how to write tests and adhere to existing coding style. 🙇
I've dropped some minor remarks. If you can address those, the rest LGTM.
log4j-core/src/main/java/org/apache/logging/log4j/core/message/ExtendedThreadInformation.java
Outdated
Show resolved
Hide resolved
Thanks for your warm words. I've just applied the changes. |
Hallo @vy, it's ready for review again |
@PAX523, we have recently changed our CI workflows, all commits must be signed. Would you mind signing your commits (using |
ca7ad63
to
3611e9f
Compare
Fix ArrayIndexOutOfBoundsException on invocation of Message.getFormattedMessage() when any thread has no stack trace, which occurs on some JVM implementations.
Updated `getStackTraceElement` to return null instead of a placeholder when stack trace is empty. Added null checks to ensure safety when accessing class name and method name, and replaced string comparisons with null-safe constants. $ Please enter the commit message for your changes. Lines starting $ with '$' will be kept; you may remove them yourself if you want to. $ An empty message aborts the commit. $ $ Date: Mon May 12 07:03:30 2025 +0200 $ $ On branch 2.x $ Your branch is up to date with 'origin/2.x'. $ $ Changes to be committed: $ modified: log4j-core/src/main/java/org/apache/logging/log4j/core/message/ExtendedThreadInformation.java $
@vy phew... it's done! |
Good morning @vy. What's the expected workflow now? When will this PR be merged? |
@PAX523, thanks so much.
Maintainers finding time to check the commits are not tampered, kick CI, and get it merged upon success. |
Fix
ArrayIndexOutOfBoundsException
on invocation ofMessage.getFormattedMessage()
when any thread has no stack trace, which occurs on some JVM implementations.See issue: #3214
The mentioned method retrieves detail information about all existing threads and collects it in a result string. One of the information are the stack traces. Some JVM implementations (such as OpenJ9) have an empty stack trace of threads in a specific state. This, in turn, results in a
ArrayIndexOutOfBoundsException
if the user tries to dump all thread information viaorg.apache.logging.log4j.message.ThreadDumpMessage.ThreadDumpMessage(String)
.Checklist
2.x
branch if you are targeting Log4j 2; usemain
otherwise./mvnw verify
succeeds (if it fails due to code formatting issues reported by Spotless, simply run./mvnw spotless:apply
and retry)src/changelog/.2.x.x
directory