Fix potential NullPointerException in RateLimiter

This commit is contained in:
Chris Eager authored and Chris Eager committed 2021-04-30 16:15:36 -05:00
1 parent cd6b2512e1
commit 0e6cfb460d
1 file changed
+9 -6
@@ -132,14 +132,17 @@ public class RateLimiter {
logger.warn("Deserialization error", e);
}
try {
final String serialized = secondaryCacheCluster.withCluster(connection -> connection.sync().get(getBucketName(key)));
if (secondaryCacheCluster != null) {
try {
final String serialized = secondaryCacheCluster
.withCluster(connection -> connection.sync().get(getBucketName(key)));
if (serialized != null) {
return LeakyBucket.fromSerialized(mapper, serialized);
if (serialized != null) {
return LeakyBucket.fromSerialized(mapper, serialized);
}
} catch (IOException e) {
logger.warn("Deserialization error", e);
}
} catch (IOException e) {
logger.warn("Deserialization error", e);
}
return new LeakyBucket(bucketSize, leakRatePerMillis);