Source:
public KieServerSetup connect(KieServerInfo serverInfo) { KieServerState currentState = context.getStateRepository().load(KieServerEnvironment.getServerId()); Set<String> controllers = currentState.getControllers(); this.serverInfo = serverInfo; KieServerConfig config = currentState.getConfiguration(); if (controllers != null && !controllers.isEmpty()) { for (String controllerUrl : controllers) { if (controllerUrl != null && !controllerUrl.isEmpty()) { if (controllerUrl.toLowerCase().startsWith("ws") || controllerUrl.toLowerCase().startsWith("wss")) { String connectAndSyncUrl = controllerUrl + "/" + KieServerEnvironment.getServerId(); final KieServerSetup kieServerSetup = new KieServerSetup(); try { this.client.init(connectAndSyncUrl, config); CountDownLatch waitLatch = new CountDownLatch(1); client.sendWithHandler(serialize(serverInfo), new KieServerSetupMessageHandler(context, waitLatch, kieServerSetup)); boolean received = waitLatch.await(10, TimeUnit.SECONDS); if (received && kieServerSetup.getContainers() != null) { return kieServerSetup; } break; } catch (Exception e) { logger.warn("Exception encountered while syncing with controller at error {}", connectAndSyncUrl, e.getCause() == null ? e.getMessage() : e.getCause().getMessage()); logger.debug("Exception encountered while syncing with controller at error {}", connectAndSyncUrl, e.getMessage(), e); } } else { logger.info("Kie Server points to non websocket controller '{}', using default REST mechanism", controllerUrl); KieServerSetup kieServerSetup = restController.connectToSingleController(serverInfo, config, controllerUrl); if (kieServerSetup != null) { return kieServerSetup; } } } } throw new KieControllerNotConnectedException("Unable to connect to any controller"); } else { throw new KieControllerNotDefinedException("Unable to connect to any controller"); } }

Target:
public KieServerSetup connect(KieServerInfo serverInfo) { KieServerState currentState = context.getStateRepository().load(KieServerEnvironment.getServerId()); Set<String> controllers = currentState.getControllers(); this.serverInfo = serverInfo; KieServerConfig config = currentState.getConfiguration(); if (controllers != null && !controllers.isEmpty()) { for (String controllerUrl : controllers) { if (controllerUrl != null && !controllerUrl.isEmpty()) { if (controllerUrl.toLowerCase().startsWith("ws")) { String connectAndSyncUrl = controllerUrl + "/" + KieServerEnvironment.getServerId(); final KieServerSetup kieServerSetup = new KieServerSetup(); try { this.client.init(connectAndSyncUrl, config); CountDownLatch waitLatch = new CountDownLatch(1); client.sendWithHandler(serialize(serverInfo), new KieServerSetupMessageHandler(context, waitLatch, kieServerSetup)); boolean received = waitLatch.await(10, TimeUnit.SECONDS); if (received && kieServerSetup.getContainers() != null) { return kieServerSetup; } break; } catch (Exception e) { logger.warn("Exception encountered while syncing with controller at error {}", connectAndSyncUrl, e.getCause() == null ? e.getMessage() : e.getCause().getMessage()); logger.debug("Exception encountered while syncing with controller at error {}", connectAndSyncUrl, e.getMessage(), e); } } else { logger.info("Kie Server points to non websocket controller '{}', using default REST mechanism", controllerUrl); KieServerSetup kieServerSetup = restController.connectToSingleController(serverInfo, config, controllerUrl); if (kieServerSetup != null) { return kieServerSetup; } } } } throw new KieControllerNotConnectedException("Unable to connect to any controller"); } else { throw new KieControllerNotDefinedException("Unable to connect to any controller"); } }