nrknithin commented on code in PR #4270:
URL:
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4270#discussion_r3240248959
##########
quarkus/addons/persistence/infinispan/health/src/main/java/org/kie/kogito/infinispan/health/InfinispanHealthCheck.java:
##########
@@ -54,49 +49,25 @@ public InfinispanHealthCheck(Instance<RemoteCacheManager>
cacheManagerInstance)
@Override
public HealthCheckResponse call() {
return cacheManagerOptional.map(cacheManager -> {
-
- final ChannelFactory channelFactory =
cacheManager.getChannelFactory();
- final Configuration configuration =
cacheManager.getConfiguration();
- final ClientListenerNotifier listenerNotifier = new
ClientListenerNotifier(
- cacheManager.getMarshaller(),
- channelFactory,
- configuration);
- final OperationsFactory operationsFactory = new
OperationsFactory(channelFactory,
- listenerNotifier,
- configuration);
-
- return Optional.of(channelFactory
- .getServers()
- .stream()
- .map(server -> invokePingOperation(channelFactory,
operationsFactory, server)
- .thenApply(PingResponse::isSuccess)
- .exceptionally(ex -> false))
- .map(op -> {
- try {
- return op.get(500, TimeUnit.MILLISECONDS);
- } catch (Exception e) {
- return false;
- }
- })
- .allMatch(Boolean.FALSE::equals))
- .map(allDown -> buildResponse(channelFactory, !allDown))
- .orElse(buildResponse(channelFactory, false));
+ boolean up;
+ try {
+ cacheManager.getCacheNames();
+ up = true;
+ } catch (Exception ex) {
+ up = false;
+ }
+ return buildResponse(cacheManager, up);
}).orElse(null);
}
- private HealthCheckResponse buildResponse(ChannelFactory channelFactory,
boolean state) {
+ private HealthCheckResponse buildResponse(RemoteCacheManager cacheManager,
boolean state) {
return HealthCheckResponse.builder()
- .withData("nodes",
Optional.ofNullable(channelFactory.getServers())
- .orElse(Collections.emptyList())
- .stream()
- .map(String::valueOf)
+ .withData("nodes",
Optional.ofNullable(cacheManager.getServers())
+ .map(Stream::of)
+ .orElseGet(Stream::empty)
.collect(Collectors.joining(",")))
Review Comment:
Switched to Arrays::stream so the conversion is explicit — the original
Stream::of worked here because Infinispan 15.x's getServers() returns String[]
and the compiler picks the varargs overload, but Arrays::stream is more obvious
to a reader. Local build (173/173 modules) confirms both forms compile.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]