diff --git a/concurrency-limits-core/src/main/java/com/netflix/concurrency/limits/limiter/AbstractLimiter.java b/concurrency-limits-core/src/main/java/com/netflix/concurrency/limits/limiter/AbstractLimiter.java index e4cb9e0..374a537 100644 --- a/concurrency-limits-core/src/main/java/com/netflix/concurrency/limits/limiter/AbstractLimiter.java +++ b/concurrency-limits-core/src/main/java/com/netflix/concurrency/limits/limiter/AbstractLimiter.java @@ -30,6 +30,21 @@ public abstract class AbstractLimiter implements Limiter { public static final String ID_TAG = "id"; public static final String STATUS_TAG = "status"; + private static final Listener NOOP_LISTENER = new Listener() { + @Override + public void onSuccess() { + } + @Override + public void onIgnore() { + } + @Override + public void onDropped() { + } + @Override + public String toString() { + return "{NoopListener}"; + } + }; public abstract static class Builder> { private static final AtomicInteger idCounter = new AtomicInteger(); @@ -128,23 +143,7 @@ protected Optional createRejectedListener() { protected Optional createBypassListener() { this.bypassCounter.increment(); - return Optional.of(new Listener() { - - @Override - public void onSuccess() { - // Do nothing - } - - @Override - public void onIgnore() { - // Do nothing - } - - @Override - public void onDropped() { - // Do nothing - } - }); + return Optional.of(NOOP_LISTENER); } protected Listener createListener() {