Skip to content

Commit 8a0e617

Browse files
Feedback
1 parent 42f2988 commit 8a0e617

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

java/core/src/main/java/co/worklytics/psoxy/gateway/impl/CachingConfigServiceDecorator.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.concurrent.ExecutionException;
99
import java.util.concurrent.TimeUnit;
1010
import java.util.stream.Collectors;
11+
1112
import com.google.common.annotations.VisibleForTesting;
1213
import com.google.common.base.Ticker;
1314
import com.google.common.cache.CacheBuilder;
@@ -77,25 +78,22 @@ LoadingCache<ConfigProperty, String> getCache() {
7778
public String load(@NonNull ConfigProperty key) {
7879
TransientConfigException lastException = null;
7980
for (int attempt = 0; attempt < MAX_TRANSIENT_RETRIES; attempt++) {
80-
if (attempt > 0) {
81-
try {
82-
if (transientRetryDelayMs > 0) Thread.sleep(transientRetryDelayMs);
83-
} catch (InterruptedException ie) {
84-
Thread.currentThread().interrupt();
85-
throw new TransientConfigException("Config load for " + key.name() + " interrupted during retry", ie);
86-
}
87-
log.log(Level.WARNING, "Retrying config property {0}, attempt {1}/{2}",
88-
new Object[]{key.name(), attempt + 1, MAX_TRANSIENT_RETRIES});
89-
}
9081
try {
9182
return delegate.getConfigPropertyAsOptional(key).orElse(NEGATIVE_VALUE);
9283
} catch (TransientConfigException e) {
9384
lastException = e;
94-
log.log(Level.WARNING, "Transient failure on attempt {0}/{1} for config property {2}",
95-
new Object[]{attempt + 1, MAX_TRANSIENT_RETRIES, key.name()});
85+
log.log(Level.WARNING, String.format("Transient failure on attempt {0}/{1} for config property {2}",
86+
attempt + 1, MAX_TRANSIENT_RETRIES, key.name()));
87+
}
88+
try {
89+
if (transientRetryDelayMs > 0)
90+
Thread.sleep(transientRetryDelayMs);
91+
} catch (InterruptedException ie) {
92+
Thread.currentThread().interrupt();
93+
throw new TransientConfigException("Config load for " + key.name() + " interrupted during retry", ie);
9694
}
9795
}
98-
throw Objects.requireNonNull(lastException);
96+
throw lastException;
9997
}
10098

10199
@Override

0 commit comments

Comments
 (0)