You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2021/07/08 08:50:05 UTC
[james-project] 02/08: JAMES-3610 Size::parse can throw
IllegalArgumentException instead of Exception
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 2808eb9aa97c0d34c65fa580cc229b9bb9059dfd
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed Jul 7 14:57:19 2021 +0700
JAMES-3610 Size::parse can throw IllegalArgumentException instead of Exception
Unchecked and more specific
---
.../org/apache/james/modules/mailbox/TikaConfigurationReader.java | 3 +--
.../container/util/src/main/java/org/apache/james/util/Size.java | 8 ++++----
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/server/container/guice/elasticsearch/src/main/java/org/apache/james/modules/mailbox/TikaConfigurationReader.java b/server/container/guice/elasticsearch/src/main/java/org/apache/james/modules/mailbox/TikaConfigurationReader.java
index 341f838..69a677e 100644
--- a/server/container/guice/elasticsearch/src/main/java/org/apache/james/modules/mailbox/TikaConfigurationReader.java
+++ b/server/container/guice/elasticsearch/src/main/java/org/apache/james/modules/mailbox/TikaConfigurationReader.java
@@ -31,7 +31,6 @@ import org.apache.james.util.DurationParser;
import org.apache.james.util.Size;
import org.apache.james.util.StreamUtils;
-import com.github.fge.lambdas.Throwing;
import com.google.common.collect.ImmutableSet;
public class TikaConfigurationReader {
@@ -67,7 +66,7 @@ public class TikaConfigurationReader {
Optional<Long> cacheWeight = Optional.ofNullable(
configuration.getString(TIKA_CACHE_WEIGHT_MAX, null))
- .map(Throwing.function(Size::parse))
+ .map(Size::parse)
.map(Size::asBytes);
Set<MimeType> contentTypeBlacklist = StreamUtils
diff --git a/server/container/util/src/main/java/org/apache/james/util/Size.java b/server/container/util/src/main/java/org/apache/james/util/Size.java
index 617fb1c..2db7dd6 100644
--- a/server/container/util/src/main/java/org/apache/james/util/Size.java
+++ b/server/container/util/src/main/java/org/apache/james/util/Size.java
@@ -54,11 +54,11 @@ public class Size {
this.value = value;
}
- public static Size parse(String providedLongWithUnitString) throws Exception {
+ public static Size parse(String providedLongWithUnitString) {
return parse(providedLongWithUnitString, Unit.NoUnit);
}
- public static Size parse(String providedLongWithUnitString, Unit defaultUnit) throws Exception {
+ public static Size parse(String providedLongWithUnitString, Unit defaultUnit) {
if (providedLongWithUnitString.equalsIgnoreCase(UNKNOWN)) {
return new Size(Unit.NoUnit, UNKNOWN_VALUE);
}
@@ -115,7 +115,7 @@ public class Size {
}
}
- private static Unit getUnit(char lastChar, Unit defaultUnit) throws Exception {
+ private static Unit getUnit(char lastChar, Unit defaultUnit) {
switch (lastChar) {
case 'K' :
case 'k' :
@@ -141,7 +141,7 @@ public class Size {
case '0' :
return defaultUnit;
default:
- throw new Exception("No unit corresponding to char : " + lastChar);
+ throw new IllegalArgumentException("No unit corresponding to char : " + lastChar);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org