Skip to content

Commit

Permalink
Copy collections to avoid false sharing (#5746)
Browse files Browse the repository at this point in the history
  • Loading branch information
sugmanue authored Dec 9, 2024
1 parent 07dbaeb commit 142b670
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@ public abstract class BaseRetryStrategy implements DefaultAwareRetryStrategy {

BaseRetryStrategy(Logger log, Builder builder) {
this.log = log;
this.retryPredicates = Collections.unmodifiableList(Validate.paramNotNull(builder.retryPredicates, "retryPredicates"));
this.retryPredicates = Collections.unmodifiableList(
Validate.paramNotNull(new ArrayList<>(builder.retryPredicates), "retryPredicates"));
this.maxAttempts = Validate.isPositive(builder.maxAttempts, "maxAttempts");
this.circuitBreakerEnabled = builder.circuitBreakerEnabled == null || builder.circuitBreakerEnabled;
this.backoffStrategy = Validate.paramNotNull(builder.backoffStrategy, "backoffStrategy");
this.throttlingBackoffStrategy = Validate.paramNotNull(builder.throttlingBackoffStrategy, "throttlingBackoffStrategy");
this.treatAsThrottling = Validate.paramNotNull(builder.treatAsThrottling, "treatAsThrottling");
this.exceptionCost = Validate.paramNotNull(builder.exceptionCost, "exceptionCost");
this.tokenBucketStore = Validate.paramNotNull(builder.tokenBucketStore, "tokenBucketStore");
this.defaultsAdded = Validate.paramNotNull(builder.defaultsAdded, "defaultsAdded");
this.defaultsAdded = Collections.unmodifiableSet(
Validate.paramNotNull(new HashSet<>(builder.defaultsAdded), "defaultsAdded"));
this.useClientDefaults = builder.useClientDefaults == null || builder.useClientDefaults;
}

Expand Down Expand Up @@ -425,7 +427,7 @@ public abstract static class Builder implements DefaultAwareRetryStrategy.Builde
this.throttlingBackoffStrategy = strategy.throttlingBackoffStrategy;
this.treatAsThrottling = strategy.treatAsThrottling;
this.tokenBucketStore = strategy.tokenBucketStore;
this.defaultsAdded = strategy.defaultsAdded;
this.defaultsAdded = new HashSet<>(strategy.defaultsAdded);
this.useClientDefaults = strategy.useClientDefaults;
}

Expand Down

0 comments on commit 142b670

Please sign in to comment.