This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 1497fb290866f61e170a3633c39d94b70780b9c7 Author: Benoit Tellier <btell...@linagora.com> AuthorDate: Wed Mar 27 10:17:04 2019 +0700 JAMES-2702 Improve DurationParser exception handling --- .../util/src/main/java/org/apache/james/util/DurationParser.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/server/container/util/src/main/java/org/apache/james/util/DurationParser.java b/server/container/util/src/main/java/org/apache/james/util/DurationParser.java index 9e1095e..f30fb6d 100644 --- a/server/container/util/src/main/java/org/apache/james/util/DurationParser.java +++ b/server/container/util/src/main/java/org/apache/james/util/DurationParser.java @@ -84,20 +84,14 @@ public class DurationParser { public static Duration parse(String rawString, ChronoUnit defaultUnit) throws NumberFormatException { Matcher res = PATTERN.matcher(rawString); if (res.matches()) { - if (res.group(AMOUNT) != null && res.group(UNIT) != null) { long time = Integer.parseInt(res.group(AMOUNT).trim()); return parseUnitAsDuration(res.group(UNIT)) .orElse(defaultUnit.getDuration()) .multipliedBy(time); - } else { - // This should never Happen anyway throw an exception - throw new NumberFormatException("The supplied String is not a supported format " + rawString); } - } else { - // The rawString not match our pattern. So its not supported - throw new NumberFormatException("The supplied String is not a supported format " + rawString); } + throw new NumberFormatException("The supplied String is not a supported format " + rawString); } private static Optional<Duration> parseUnitAsDuration(String unit) { --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org