Skip to content
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

Handle additional StackTraceElement fields in JDK 9 #1640

Closed
ppkarwasz opened this issue Jul 31, 2023 · 0 comments · Fixed by #1641
Closed

Handle additional StackTraceElement fields in JDK 9 #1640

ppkarwasz opened this issue Jul 31, 2023 · 0 comments · Fixed by #1641
Assignees
Milestone

Comments

@ppkarwasz
Copy link
Contributor

When running on JDK 9+ the StackTraceElement class has three additional fields: classLoaderName, moduleName and moduleVersion.

These fields:

  • are not used in the stack trace formatter, so stack traces formatted by Log4j differ from StackTraceElement.toString(),
  • are lost during serialization of ExtendedStackTraceElement, so a deserialized element differs from the original,
  • are automatically serialized by Jackson, when serializing an event's location. Such an event can not be deserialized.

These problems amount to the majority of test failures under JDK 11. This blocks #1369.

An example of serialized event:

  <Event xmlns="http://logging.apache.org/log4j/2.0/events" timeMillis="1690783320311" thread="main" level="INFO" loggerName="eu.copernik.log4j.test.XmlTest" endOfBatch="false" loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger" threadId="1" threadPriority="5">
    <Instant epochSecond="1690783320" nanoOfSecond="311415800"/>
    <Message>Hello world!</Message>
    <Source class="eu.copernik.log4j.test.XmlTest" method="main" file="XmlTest.java" line="14">
      <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="main" file="XmlTest.java" line="13" exact="true" location="classes/" version="?"/>
      </ExtendedStackTrace>
    </Thrown>
  </Event>
@ppkarwasz ppkarwasz added this to the 2.20.1 milestone Jul 31, 2023
@ppkarwasz ppkarwasz self-assigned this Jul 31, 2023
ppkarwasz added a commit to ppkarwasz/logging-log4j2 that referenced this issue Jul 31, 2023
ppkarwasz added a commit to ppkarwasz/logging-log4j2 that referenced this issue Aug 2, 2023
ppkarwasz added a commit to ppkarwasz/logging-log4j2 that referenced this issue Aug 2, 2023
Closes apache#1640.

Co-authored-by: Ralph Goers <rgoers@apache.org>
ppkarwasz added a commit to ppkarwasz/logging-log4j2 that referenced this issue Aug 2, 2023
Closes apache#1640.

Co-authored-by: Ralph Goers <rgoers@apache.org>
ppkarwasz added a commit to ppkarwasz/logging-log4j2 that referenced this issue Aug 2, 2023
Closes apache#1640.

Co-authored-by: Ralph Goers <rgoers@apache.org>
ppkarwasz added a commit to ppkarwasz/logging-log4j2 that referenced this issue Aug 2, 2023
Closes apache#1640.

Co-authored-by: Ralph Goers <rgoers@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant