Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return singleton no-op Listener in createBypassListener #209

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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 @@ -128,23 +143,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
Loading