diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/async/CircuitBreaker.java b/src/main/java/ch/ethz/seb/sebserver/gbl/async/CircuitBreaker.java index 9d214d52..3f13ea72 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/async/CircuitBreaker.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/async/CircuitBreaker.java @@ -121,7 +121,7 @@ public final class CircuitBreaker { return this.lastSuccessTime; } - public Result protectedRun(final Supplier supplier) { + public synchronized Result protectedRun(final Supplier supplier) { final long currentTime = System.currentTimeMillis(); if (log.isDebugEnabled()) { diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/async/MemoizingCircuitBreaker.java b/src/main/java/ch/ethz/seb/sebserver/gbl/async/MemoizingCircuitBreaker.java index 3c78c65c..5a236a5d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/async/MemoizingCircuitBreaker.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/async/MemoizingCircuitBreaker.java @@ -124,7 +124,7 @@ public final class MemoizingCircuitBreaker implements Supplier> { } @Override - public Result get() { + public synchronized Result get() { final Result result = this.delegate.protectedRun(this.supplier); if (result.hasError()) { if (this.memoizing && this.cached != null) {