-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Adapt ExtendedStackTraceElement to Java 9+ #1641
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
After this PR a sample stacktrace changes from:
to
|
A sample XML event passes from: <Event xmlns="http://logging.apache.org/log4j/2.0/events" timeMillis="1690800041924" thread="ForkJoinPool.commonPool-worker-19" level="INFO" loggerName="eu.copernik.log4j.test.XmlTest" endOfBatch="false" loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger" threadId="15" threadPriority="5">
<Instant epochSecond="1690800041" nanoOfSecond="924573100"/>
<Message>Hello world!</Message>
<Source class="eu.copernik.log4j.test.XmlTest" method="logError" file="XmlTest.java" line="19">
<classLoaderName xmlns="">app</classLoaderName>
<moduleName xmlns="">eu.copernik.log4j.test</moduleName>
<moduleVersion xmlns="">1.0.0</moduleVersion>
</Source>
<Thrown commonElementCount="0" name="java.lang.RuntimeException">
<ExtendedStackTrace>
<ExtendedStackTraceItem class="eu.copernik.log4j.test.XmlTest" method="logError" file="XmlTest.java" line="18" exact="false" location="classes/" version="?"/>
<ExtendedStackTraceItem class="java.util.concurrent.CompletableFuture$AsyncRun" method="run" file="CompletableFuture.java" line="1736" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem class="java.util.concurrent.CompletableFuture$AsyncRun" method="exec" file="CompletableFuture.java" line="1728" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem class="java.util.concurrent.ForkJoinTask" method="doExec" file="ForkJoinTask.java" line="290" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem class="java.util.concurrent.ForkJoinPool$WorkQueue" method="topLevelExec" file="ForkJoinPool.java" line="1020" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem class="java.util.concurrent.ForkJoinPool" method="scan" file="ForkJoinPool.java" line="1656" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem class="java.util.concurrent.ForkJoinPool" method="runWorker" file="ForkJoinPool.java" line="1594" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem class="java.util.concurrent.ForkJoinWorkerThread" method="run" file="ForkJoinWorkerThread.java" line="183" exact="true" location="?" version="?"/>
</ExtendedStackTrace>
</Thrown>
</Event> to <Event xmlns="http://logging.apache.org/log4j/2.0/events" timeMillis="1690800122073" thread="ForkJoinPool.commonPool-worker-19" level="INFO" loggerName="eu.copernik.log4j.test.XmlTest" endOfBatch="false" loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger" threadId="17" threadPriority="5">
<Instant epochSecond="1690800122" nanoOfSecond="73385600"/>
<Message>Hello world!</Message>
<Source classLoaderName="app" moduleName="eu.copernik.log4j.test" moduleVersion="1.0.0" class="eu.copernik.log4j.test.XmlTest" method="logError" file="XmlTest.java" line="19"/>
<Thrown commonElementCount="0" name="java.lang.RuntimeException">
<ExtendedStackTrace>
<ExtendedStackTraceItem classLoaderName="app" moduleName="eu.copernik.log4j.test" moduleVersion="1.0.0" class="eu.copernik.log4j.test.XmlTest" method="logError" file="XmlTest.java" line="18" exact="false" location="classes/" version="?"/>
<ExtendedStackTraceItem moduleName="java.base" moduleVersion="11.0.14.1" class="java.util.concurrent.CompletableFuture$AsyncRun" method="run" file="CompletableFuture.java" line="1736" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem moduleName="java.base" moduleVersion="11.0.14.1" class="java.util.concurrent.CompletableFuture$AsyncRun" method="exec" file="CompletableFuture.java" line="1728" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem moduleName="java.base" moduleVersion="11.0.14.1" class="java.util.concurrent.ForkJoinTask" method="doExec" file="ForkJoinTask.java" line="290" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem moduleName="java.base" moduleVersion="11.0.14.1" class="java.util.concurrent.ForkJoinPool$WorkQueue" method="topLevelExec" file="ForkJoinPool.java" line="1020" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem moduleName="java.base" moduleVersion="11.0.14.1" class="java.util.concurrent.ForkJoinPool" method="scan" file="ForkJoinPool.java" line="1656" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem moduleName="java.base" moduleVersion="11.0.14.1" class="java.util.concurrent.ForkJoinPool" method="runWorker" file="ForkJoinPool.java" line="1594" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem moduleName="java.base" moduleVersion="11.0.14.1" class="java.util.concurrent.ForkJoinWorkerThread" method="run" file="ForkJoinWorkerThread.java" line="183" exact="true" location="?" version="?"/>
</ExtendedStackTrace>
</Thrown>
</Event> The JSON and YAML layouts undergo similar changes. |
ppkarwasz
force-pushed
the
stack-trace-element9
branch
5 times, most recently
from
August 2, 2023 12:13
cedda1b
to
beb1770
Compare
Closes apache#1640. Co-authored-by: Ralph Goers <rgoers@apache.org>
ppkarwasz
force-pushed
the
stack-trace-element9
branch
from
August 2, 2023 17:27
beb1770
to
381f508
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #1640.
This PR provides a JDK 9+ version of
StackTraceElement
andExtendedStackTraceElement
formatting and serialization. The formatting of these elements resembles the one used natively by the JDK:The names of the builtin classloaders ("app", "boot", "platform") are omitted, as well as the versions of the built-in modules (unless reflective access to
jdk.internal.module
is forbidden) .To test this PR, run
./mvnw verify -Pjava9-tests
. Some unrelated test failures are to be expected.