vy commented on code in PR #3469: URL: https://github.com/apache/logging-log4j2/pull/3469#discussion_r1961578893
########## log4j-core/src/main/java/org/apache/logging/log4j/core/util/internal/instant/InstantPatternDynamicFormatter.java: ########## @@ -694,39 +694,43 @@ static class SecondPatternSequence extends PatternSequence { 100_000_000, 10_000_000, 1_000_000, 100_000, 10_000, 1_000, 100, 10, 1 }; - private final boolean printSeconds; + private final int secondDigits; private final String separator; private final int fractionalDigits; - SecondPatternSequence(boolean printSeconds, String separator, int fractionalDigits) { + SecondPatternSequence(int secondDigits, String separator, int fractionalDigits) { super( - createPattern(printSeconds, separator, fractionalDigits), - determinePrecision(printSeconds, fractionalDigits)); - this.printSeconds = printSeconds; + createPattern(secondDigits, separator, fractionalDigits), + determinePrecision(secondDigits, fractionalDigits)); + if (secondDigits < 0 || secondDigits > 2) { + throw new IllegalArgumentException("Unsupported number of `s` pattern letters."); + } + if (fractionalDigits > 9) { + throw new IllegalArgumentException("Unsupported number of `S` pattern letters."); Review Comment: *Nit:* Shall we improved reported diagnostics? ```suggestion final int maxSecondDigits = 2; if (secondDigits > maxSecondDigits) { final String message = String.format( "More than %d `s` pattern letters are not supported, found: %d", maxSecondDigits, secondDigits); throw new IllegalArgumentException(message); } final int maxFractionalDigits = 9; if (fractionalDigits > maxFractionalDigits) { final String message = String.format( "More than %d `S` pattern letters are not supported, found: %d", maxFractionalDigits, fractionalDigits); throw new IllegalArgumentException(message); ``` -- 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: notifications-unsubscr...@logging.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org