Skip to content

Commit 0870bac

Browse files
ppkarwaszvy
andauthored
Apply review suggestions (1)
Co-authored-by: Volkan Yazıcı <[email protected]>
1 parent 04c56a9 commit 0870bac

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

log4j-core/src/main/java/org/apache/logging/log4j/core/util/internal/instant/InstantPatternDynamicFormatter.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -702,11 +702,19 @@ static class SecondPatternSequence extends PatternSequence {
702702
super(
703703
createPattern(secondDigits, separator, fractionalDigits),
704704
determinePrecision(secondDigits, fractionalDigits));
705-
if (secondDigits < 0 || secondDigits > 2) {
706-
throw new IllegalArgumentException("Unsupported number of `s` pattern letters.");
705+
final int maxSecondDigits = 2;
706+
if (secondDigits > maxSecondDigits) {
707+
final String message = String.format(
708+
"More than %d `s` pattern letters are not supported, found: %d",
709+
maxSecondDigits, secondDigits);
710+
throw new IllegalArgumentException(message);
707711
}
708-
if (fractionalDigits > 9) {
709-
throw new IllegalArgumentException("Unsupported number of `S` pattern letters.");
712+
final int maxFractionalDigits = 9;
713+
if (fractionalDigits > maxFractionalDigits) {
714+
final String message = String.format(
715+
"More than %d `S` pattern letters are not supported, found: %d",
716+
maxFractionalDigits, fractionalDigits);
717+
throw new IllegalArgumentException(message);
710718
}
711719
this.secondDigits = secondDigits;
712720
this.separator = separator;

0 commit comments

Comments
 (0)