Copilot commented on code in PR #4270:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4270#discussion_r3239928237


##########
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:
   `Collectors.joining(",")` requires a `Stream<CharSequence>`, but the current 
pipeline streams the return value of `cacheManager.getServers()` without 
converting elements to strings. This will either not compile or will join a 
single collection/array object rather than individual servers. Convert the 
returned servers to a stream of individual server addresses and 
`map(String::valueOf)` before joining (e.g., handle `Collection`/array 
properly) so the `nodes` field contains a comma-separated list of servers as 
intended.



-- 
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]

Reply via email to