Source:
protected boolean send(String url, String containerId, String payload, boolean add, boolean retry) { try { KieServerHttpRequest httpRequest = null; if (password != null && !password.isEmpty()) { httpRequest = KieServerHttpRequest.newRequest(url, serverId, password); } else { httpRequest = KieServerHttpRequest.newRequest(url); } httpRequest.followRedirects(true) .contentType("application/json") .accept("application/json") .timeout(5000) .body(payload) .post(); KieServerHttpResponse response = httpRequest.response(); int responseCode = response.code(); logger.debug("Response for url is {}", httpRequest.getUrl(), responseCode); if (responseCode > 201) { throw new KieServerHttpRequestException("Connection error " + responseCode); } observer.onSuccess(url); return true; } catch (KieServerHttpRequestException ioe) { logger.debug("Send to router failed", ioe); if (retry) { executorService.schedule(() -> { boolean success = send(url, containerId, payload, add, true); if (success) { if (add) { logger.info("Added '{}' as server location for container '{}'", serverURL, containerId); } else { logger.info("Removed '{}' as server location for container '{}'", serverURL, containerId); } } }, failedAttemptsInterval, TimeUnit.SECONDS); logger.warn("Failed at sending request to router at due to {}. Next attempt is scheduled to fire in seconds", url, findCause(ioe).getMessage(), failedAttemptsInterval); } else { logger.warn("Failed at sending request to router at due to {}.", url, findCause(ioe).getMessage()); } observer.onFailure(url); return false; } catch (Exception e) { logger.warn("Failed at sending request to router at due to {}", url, findCause(e).getMessage()); logger.debug("Send to router failed", e); return false; } }

Target:
protected boolean send(String url, String containerId, String payload, boolean add, boolean retry) { try { KieServerHttpRequest httpRequest = null; if (password != null && !password.isEmpty()) { httpRequest = KieServerHttpRequest.newRequest(url, username, password); } else { httpRequest = KieServerHttpRequest.newRequest(url); } httpRequest.followRedirects(true) .contentType("application/json") .accept("application/json") .timeout(5000) .body(payload) .post(); KieServerHttpResponse response = httpRequest.response(); int responseCode = response.code(); logger.debug("Response for url is {}", httpRequest.getUrl(), responseCode); if (responseCode > 201) { throw new KieServerHttpRequestException("Connection error " + responseCode); } observer.onSuccess(url); return true; } catch (KieServerHttpRequestException ioe) { logger.debug("Send to router failed", ioe); if (retry) { executorService.schedule(() -> { boolean success = send(url, containerId, payload, add, true); if (success) { if (add) { logger.info("Added '{}' as server location for container '{}'", serverURL, containerId); } else { logger.info("Removed '{}' as server location for container '{}'", serverURL, containerId); } } }, failedAttemptsInterval, TimeUnit.SECONDS); logger.warn("Failed at sending request to router at due to {}. Next attempt is scheduled to fire in seconds", url, findCause(ioe).getMessage(), failedAttemptsInterval); } else { logger.warn("Failed at sending request to router at due to {}.", url, findCause(ioe).getMessage()); } observer.onFailure(url); return false; } catch (Exception e) { logger.warn("Failed at sending request to router at due to {}", url, findCause(e).getMessage()); logger.debug("Send to router failed", e); return false; } }