Skip to content

Commit

Permalink
Merge pull request #209 from kilink/noop-listener-create-bypass-listener
Browse files Browse the repository at this point in the history
Return singleton no-op Listener in createBypassListener
  • Loading branch information
kilink authored Sep 18, 2024
2 parents daebd31 + 65413bd commit 450aa7a
Showing 1 changed file with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@
public abstract class AbstractLimiter<ContextT> implements Limiter<ContextT> {
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<BuilderT extends Builder<BuilderT>> {
private static final AtomicInteger idCounter = new AtomicInteger();
Expand Down Expand Up @@ -138,23 +153,7 @@ protected Optional<Listener> createRejectedListener() {

protected Optional<Listener> 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() {
Expand Down

0 comments on commit 450aa7a

Please sign in to comment.