Source:
public List<ServerComponentHealth> getResponses(String componentType, String componentScope, String componentInputs, DiagnosticsAware component) { List<String> hosts = getLiveInstances(); ConcurrentMap<String, String> responses = new ConcurrentHashMap<>(); hosts.parallelStream().forEach(hostName -> { ServerComponentHealthRestClient restClient = null; try { String dmsUri = getDmsUri(hostName); LOG.info("Send restli status request to " + dmsUri); restClient = ServerComponentHealthRestClientFactory.getClient(dmsUri, Collections.singletonMap( HttpClientFactory.HTTP_REQUEST_TIMEOUT, HTTP_TIMEOUT)); ServerComponentHealth response = null; String errorMessage = ""; try { response = restClient.getStatus(componentType, componentScope, componentInputs); } catch (Exception e) { errorMessage = "Received REST exception " + e.toString() + " from the host: " + dmsUri; LOG.error("Received REST exception from the host: {}", dmsUri, e); } finally { if (response == null && errorMessage.isEmpty()) { errorMessage = "Failed to receive REST response from the host: " + dmsUri; LOG.error(errorMessage); } if (!errorMessage.isEmpty()) { responses.put(hostName, errorMessage); } else { String message = "Received REST response from the host: " + dmsUri + " with status: " + response.getStatus(); LOG.info(message); responses.put(hostName, response.getStatus()); } } } finally { if (restClient != null) { restClient.shutdown(); } } }); ServerComponentHealth serverComponentHealth = new ServerComponentHealth(); serverComponentHealth.setStatus(component.reduce(componentInputs, responses)); return Arrays.asList(serverComponentHealth); }

Target:
public List<ServerComponentHealth> getResponses(String componentType, String componentScope, String componentInputs, DiagnosticsAware component) { List<String> hosts = getLiveInstances(); ConcurrentMap<String, String> responses = new ConcurrentHashMap<>(); hosts.parallelStream().forEach(hostName -> { ServerComponentHealthRestClient restClient = null; try { String dmsUri = getDmsUri(hostName); LOG.info("Send restli status request to " + dmsUri); restClient = ServerComponentHealthRestClientFactory.getClient(dmsUri, Collections.singletonMap( HttpClientFactory.HTTP_REQUEST_TIMEOUT, HTTP_TIMEOUT)); ServerComponentHealth response = null; String errorMessage = ""; try { response = restClient.getStatus(componentType, componentScope, componentInputs); } catch (Exception e) { errorMessage = "Received REST exception: " + e.toString() + " from the host: " + dmsUri; LOG.error("Received REST exception from the host: {}", dmsUri, e); } finally { if (response == null && errorMessage.isEmpty()) { errorMessage = "Failed to receive REST response from the host: " + dmsUri; LOG.error(errorMessage); } if (!errorMessage.isEmpty()) { responses.put(hostName, errorMessage); } else { String message = "Received REST response from the host: " + dmsUri + " with status: " + response.getStatus(); LOG.info(message); responses.put(hostName, response.getStatus()); } } } finally { if (restClient != null) { restClient.shutdown(); } } }); ServerComponentHealth serverComponentHealth = new ServerComponentHealth(); serverComponentHealth.setStatus(component.reduce(componentInputs, responses)); return Arrays.asList(serverComponentHealth); }