DomGarguilo commented on a change in pull request #1965:
URL: https://github.com/apache/accumulo/pull/1965#discussion_r594629636



##########
File path: 
core/src/main/java/org/apache/accumulo/core/util/ratelimit/SharedRateLimiterFactory.java
##########
@@ -87,12 +90,12 @@ public static synchronized SharedRateLimiterFactory 
getInstance(AccumuloConfigur
   public RateLimiter create(String name, RateProvider rateProvider) {
     synchronized (activeLimiters) {
       if (activeLimiters.containsKey(name)) {
-        return activeLimiters.get(name);
+        return activeLimiters.get(name).get();
       } else {
         long initialRate;
         initialRate = rateProvider.getDesiredRate();
         SharedRateLimiter limiter = new SharedRateLimiter(name, rateProvider, 
initialRate);
-        activeLimiters.put(name, limiter);
+        activeLimiters.put(name, new WeakReference<>(limiter));
         return limiter;

Review comment:
       5c274bf should address your suggestions @ctubbsii. I'm not sure if I 
understand your suggestion on using a lambda: 
    
   > Also, this whole if/else block may be more easily implemented inside a 
lambda passed to `activeLimiters.compute()`.
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to