From 1bde9b1177ec697d451995a24b51d266011fc94b Mon Sep 17 00:00:00 2001 From: brycezhongqing Date: Tue, 2 Jan 2024 19:32:07 -0800 Subject: [PATCH] resolve comments --- .../d2/balancer/dualread/DualReadStateManager.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadStateManager.java b/d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadStateManager.java index f513b35d74..1c9bb3195e 100644 --- a/d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadStateManager.java +++ b/d2/src/main/java/com/linkedin/d2/balancer/dualread/DualReadStateManager.java @@ -188,16 +188,14 @@ public void checkAndSwitchMode(String d2ServiceName) LOG.info("Dual read mode executor is shut down already. Skipping getting the latest dual read mode."); return; } - + if (d2ServiceName == null) + { + return; + } _executorService.execute(() -> { - if(d2ServiceName == null){ - return; - } - RateLimiter serviceRateLimiter = _serviceToRateLimiterMap.computeIfAbsent( - d2ServiceName, - key -> RateLimiter.create((double) 1 / DUAL_READ_MODE_SWITCH_MIN_INTERVAL) - ); + RateLimiter serviceRateLimiter = _serviceToRateLimiterMap.computeIfAbsent(d2ServiceName, + key -> RateLimiter.create((double) 1 / DUAL_READ_MODE_SWITCH_MIN_INTERVAL)); boolean shouldCheck = serviceRateLimiter.tryAcquire(); if (shouldCheck) {