sczyh30 / vertx-blueprint-microservice

Vert.x Blueprint Project - Micro-Shop microservice application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in HealthCheck for services

a-marcel opened this issue · comments

Hi,

in the file https://github.com/sczyh30/vertx-blueprint-microservice/blob/master/api-gateway/src/main/java/io/vertx/blueprint/microservice/gateway/APIGatewayVerticle.java

method: sendHeartBeatRequest

boolean notHealthy = statusList.anyMatch(status -> !status.getBoolean("status"));

        if (notHealthy) {
          String issues = statusList.filter(status -> !status.getBoolean("status"))
            .map(status -> status.getString("name"))
            .collect(Collectors.joining(", "));

          String err = String.format("Heart beat check fail: %s", issues);
          // publish log
          publishGatewayLog(err);
          return Future.failedFuture(new IllegalStateException(err));
        } else {
          // publish log
          publishGatewayLog("api_gateway_heartbeat_check_success");
          return Future.succeededFuture("OK");
        }

this code block will not work in an error case and don't log any error. After using the stream with notHealthy = statusList.anyMatch you cannot use the same stream again in statusList.filter

it will result in

java.lang.IllegalStateException: stream has already been operated upon or closed

Marcel

Thanks for reporting this!