Skip to content

Commit 28e8b4a

Browse files
committed
fixed random to be thread safe #2973
1 parent dfe6753 commit 28e8b4a

File tree

1 file changed

+5
-2
lines changed
  • rate-limiting-pattern/src/main/java/com/iluwatar/rate/limiting/pattern

1 file changed

+5
-2
lines changed

rate-limiting-pattern/src/main/java/com/iluwatar/rate/limiting/pattern/App.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static Runnable createClientTask(
106106
return () -> {
107107
String[] services = {"s3", "dynamodb", "lambda"};
108108
String[] operations = {
109-
"GetObject", "PutObject", "Query", "Scan", "PutItem", "Invoke", "ListFunctions"
109+
"GetObject", "PutObject", "Query", "Scan", "PutItem", "Invoke", "ListFunctions"
110110
};
111111
SecureRandom random = new SecureRandom(); // ✅ Safe & compliant for SonarCloud
112112

@@ -139,7 +139,10 @@ static void makeRequest(int clientId, RateLimiter limiter, String service, Strin
139139
throttledRequests.incrementAndGet();
140140
LOGGER.warn(
141141
"Client {}: {}.{} - THROTTLED (Retry in {}ms)",
142-
clientId, service, operation, e.getRetryAfterMillis());
142+
clientId,
143+
service,
144+
operation,
145+
e.getRetryAfterMillis());
143146
} catch (ServiceUnavailableException e) {
144147
failedRequests.incrementAndGet();
145148
LOGGER.warn("Client {}: {}.{} - SERVICE UNAVAILABLE", clientId, service, operation);

0 commit comments

Comments
 (0)