made CircuitBreaker thread safe

This commit is contained in:
anhefti 2021-05-12 08:11:41 +02:00
parent 5e4404c1b5
commit a46e2c0b27
2 changed files with 2 additions and 2 deletions

View file

@ -121,7 +121,7 @@ public final class CircuitBreaker<T> {
return this.lastSuccessTime;
}
public Result<T> protectedRun(final Supplier<T> supplier) {
public synchronized Result<T> protectedRun(final Supplier<T> supplier) {
final long currentTime = System.currentTimeMillis();
if (log.isDebugEnabled()) {

View file

@ -124,7 +124,7 @@ public final class MemoizingCircuitBreaker<T> implements Supplier<Result<T>> {
}
@Override
public Result<T> get() {
public synchronized Result<T> get() {
final Result<T> result = this.delegate.protectedRun(this.supplier);
if (result.hasError()) {
if (this.memoizing && this.cached != null) {