Error in HealthCheck for services
a-marcel opened this issue · comments
Marcel commented
Hi,
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
Eric Zhao commented
Thanks for reporting this!