SebTardif opened a new pull request, #4220:
URL: https://github.com/apache/logging-log4j2/pull/4220
## What Problem This Solves
`InstantPatternLegacyFormatter` computed precision by constructing
`InstantPatternDynamicFormatter` with the **legacy** pattern string. Legacy
FixedDateFormat patterns use `n` for variable-length fractional seconds.
DateTimeFormatter treats `n` as always nano-of-second, so patterns such as
`yyyy-MM-dd HH:mm:ss,nnnnnn` were classified as `NANOS` instead of `MICROS`,
breaking cache invalidation for legacy formatters.
## Evidence
Issue #3816. Approach matches ppkarwasz's fix on main (`n` → `S` before
precision detection), which was not present on `2.x`.
### Red-green
Without the fix:
```
expected: Micros
but was: Nanos
```
With the fix:
```bash
export JAVA_HOME=$(/usr/libexec/java_home -v 17)
./mvnw -pl log4j-core,log4j-core-test -am test \
-Dtest=InstantPatternLegacyFormatterPrecisionTest,NamedInstantPatternTest \
-Dsurefire.failIfNoSpecifiedTests=false
```
`InstantPatternLegacyFormatterPrecisionTest`: 2 passed
`NamedInstantPatternTest`: 21 passed (also asserts legacy/modern precision
parity)
## Summary
- Map legacy `n` to `S` only for precision detection
- Dedicated precision unit tests + NamedInstantPattern precision assertion
- Changelog; Fixes #3816
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]