ppkarwasz commented on code in PR #3789:
URL: https://github.com/apache/logging-log4j2/pull/3789#discussion_r2197874778
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/util/internal/instant/InstantPatternLegacyFormatter.java:
##########
@@ -46,7 +46,10 @@ final class InstantPatternLegacyFormatter implements
InstantPatternFormatter {
private final BiConsumer<StringBuilder, Instant> formatter;
InstantPatternLegacyFormatter(final String pattern, final Locale locale,
final TimeZone timeZone) {
- this.precision = new InstantPatternDynamicFormatter(pattern, locale,
timeZone).getPrecision();
+ // Replaces 'n' used in legacy patterns with 'S' to obtain the right
precision.
+ // In legacy patterns, the precision of 'n' depends on the pattern
length, but
+ // in `DateTimeFormatter`, it is always nanoseconds.
+ this.precision = new
InstantPatternDynamicFormatter(pattern.replace('n', 'S'), locale,
timeZone).getPrecision();
Review Comment:
This is already a (theoretical) issue in `2.x`: patterns that should have a
precision of `MICROSECONDS` are currently classified as `NANOSECONDS`. However,
since `IPLF.getPrecision()` isn’t used anywhere in practice, this
misclassification doesn't cause any actual issues — at least not yet.
--
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]