-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
LOG4J2-3672 Avoid invoking DateFormatSymbols.getZoneStrings()
in FastDateParser
#1848
Conversation
FastDateParser
FastDateParser
DateFormatSymbols.getZoneStrings()
in FastDateParser
@tristantarrant, thanks so much for taking time to not only report the problem, but also provide a fix. 🙇 I have some concerns regarding this change. For one, it is backward incompatible, hence we cannot have your toggle enabled by default. Nevertheless, I think we don't need a toggle: Since |
Hi @vy, I agree we need a better solution.
Unfortunately this does not solve the bigger issue: if someone uses A possibility, aside from fixing this in the JDK in some way, is to install an alternate |
5fe60bd
to
03eb7d4
Compare
I have reworked the PR to lazily initialize the TZ names only if a the date pattern uses a non-GMT/RFC822-style name. A WARNing will be logged once in this case. My idea about implementing an alternate |
@tristantarrant, I haven't forgotten about this issue and your PR, but swamped with other priorities right now. Please allow me some time. |
I wasn't expecting you to act on it urgently. Take your time :) |
Figured the most recent |
@tristantarrant, the more I digged this the more I felt like you are pulling my leg. 😅 Log4j uses date parsing nowhere in the code. I can mark all date parsing related stuff as deprecated and remove them at a certain point. Though all this begs the question "How did you end up having the problem described in LOG4J2-2672?" 🤔 Are you trying to parse date using Log4j libraries? If so, why? |
Log4j does not parse dates: it parses a date formatter which is then used to print timestamps in the logs. We use the following layout: <PatternLayout pattern="%highlight{%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p (%t) [%c] %m%throwable}{INFO=normal, DEBUG=normal, TRACE=normal}%n"/> and that |
I'll create a small verifier and attach it to the issue. |
|
I apologize: I included the wrong layout. This one triggers the call: <PatternLayout pattern="%d{dd/MMM/yyyy:HH:mm:ss Z} %-5p %m%throwable%n"/> Removing the |
I've created the reproducer: https://github.com/tristantarrant/log4j-tzdb-issue |
It will generate a |
Okay, apparently |
f9766bb should have fixed the issue. @tristantarrant, would you mind confirming the fix, please? (You can either try building the sources yourself or use |
Even better: less code is my favourite code :) |
@tristantarrant, there were forgotten tests. Pushed one more commit. The new CI run: https://github.com/apache/logging-log4j2/actions/runs/6736362709 |
@vy just to let you know that our application initial heap footprint went down from ~31MB to 25MB (we also disabled initialization of JMX) thanks to this. Thanks again. |
### What changes were proposed in this pull request? The pr aims to upgrade log4j2 from 2.21.0 to 2.22.0. ### Why are the changes needed? This is the first log4j2 version that provides a CycloneDX Software Bill of Materials (SBOM) and the new version bring some new change and fix like: - Change the order of evaluation of FormattedMessage formatters. Messages are evaluated using java.util.Format only if they don't comply to the java.text.MessageFormat or ParameterizedMessage format. (apache/logging-log4j2#1223) - Change default encoding of HTTP Basic Authentication to UTF-8 and add log4j2.configurationAuthorizationEncoding property to overwrite it. (apache/logging-log4j2#1970) - Removed unused FastDateParser which was causing unnecessary heap overhead ([LOG4J2-3672](https://issues.apache.org/jira/browse/LOG4J2-3672), apache/logging-log4j2#1848) - Fix MDC pattern converter causing issues for %notEmpty (apache/logging-log4j2#1922) - Fix NotSerializableException thrown when Logger is serialized with a ReusableMessageFactory (apache/logging-log4j2#1884) the full release note as follows: -https://github.com/apache/logging-log4j2/releases/tag/rel%2F2.22.0 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Pass GitHub Actions ### Was this patch authored or co-authored using generative AI tooling? No Closes #43940 from LuciferYang/SPARK-46038. Authored-by: yangjie01 <yangjie01@baidu.com> Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
https://issues.apache.org/jira/browse//LOG4J2-3672