[ATK-4416]: update guava version (#3906)

1. update guava version to 32.1.2-jre
    2. fix npe warning
This commit is contained in:
darling
2025-06-03 13:19:35 +08:00
committed by GitHub
parent 61c7d47530
commit 3bec9399d5
2 changed files with 4 additions and 3 deletions

View File

@@ -78,7 +78,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>29.0-jre</version>
<version>32.1.2-jre</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>

View File

@@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -150,7 +151,7 @@ public final class JavaUtils {
}
// If suffix is valid use that, otherwise none was provided and use the default passed
return unit.convert(val, suffix != null ? TIME_SUFFIXES.get(suffix) : unit);
return unit.convert(val, suffix != null ? Optional.ofNullable(TIME_SUFFIXES.get(suffix)).orElse(unit) : unit);
} catch (NumberFormatException e) {
String timeError = "Time must be specified as seconds (s), " +
"milliseconds (ms), microseconds (us), minutes (m or min), hour (h), or day (d). " +
@@ -228,7 +229,7 @@ public final class JavaUtils {
}
// If suffix is valid use that, otherwise none was provided and use the default passed
return unit.convertFrom(val, suffix != null ? BYTE_SUFFIXES.get(suffix) : unit);
return unit.convertFrom(val, suffix != null ? Optional.ofNullable(BYTE_SUFFIXES.get(suffix)).orElse(unit) : unit);
} else if (fractionMatcher.matches()) {
throw new NumberFormatException("Fractional values are not supported. Input was: " +
fractionMatcher.group(1));