Skip to content

Commit

Permalink
off by one errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dashaun committed Feb 7, 2024
1 parent 633c18a commit d48f7ff
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main/java/com/javagrunt/service/gateway/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,17 @@ class RequestCountingFilter implements GatewayFilter, ScalerService {

@Override
public long getMetric(String name, String namespace) {
AtomicInteger count = getCount(name, namespace);
logger.info("Returning count: " + count.get());
return count.get();
return getCount(name, namespace).get();
}

@Override
public boolean isActive(String name, String namespace) {
AtomicInteger count = getCount(name, namespace);
logger.info("Returning active: " + (count.get() > 0));
return count.get() > 0;
return getCount(name, namespace).get() > 0;
}

@Override
public void setActive(String name, String namespace, boolean active) {
logger.info("Setting active: " + active);
AtomicInteger count = getCount(name, namespace);
if(count.get() > 0){
count.set(0);
Expand All @@ -110,6 +107,7 @@ public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
String name = r.getMetadata().get("name").toString();
String namespace = r.getMetadata().get("namespace").toString();
AtomicInteger count = getCount(name, namespace);
logger.info("Incrementing count");
count.incrementAndGet();
return this.filter.filter(exchange, chain).doOnError(e -> {
if (count.get() > 0) {
Expand Down

0 comments on commit d48f7ff

Please sign in to comment.