Source:
private AuthenticationResult processTokenResponse(HttpWebResponse webResponse) { AuthenticationResult result = new AuthenticationResult(); String correlationIdInHeader = null; if (webResponse.getResponseHeaders() != null && webResponse.getResponseHeaders().containsKey( AuthenticationConstants.AAD.CLIENT_REQUEST_ID)) { List<String> listOfHeaders = webResponse.getResponseHeaders().get( AuthenticationConstants.AAD.CLIENT_REQUEST_ID); if (listOfHeaders != null && listOfHeaders.size() > 0) { correlationIdInHeader = listOfHeaders.get(0); } } final int statusCode = webResponse.getStatusCode(); switch (statusCode) { case HttpURLConnection.HTTP_OK: case HttpURLConnection.HTTP_BAD_REQUEST: case HttpURLConnection.HTTP_UNAUTHORIZED: try { result = parseJsonResponse(webResponse.getBody()); } catch (final JSONException jsonException) { Logger.e(TAG, jsonException.getMessage(), "", ADALError.SERVER_INVALID_JSON_RESPONSE, jsonException); result = new AuthenticationResult(JSON_PARSING_ERROR, jsonException.getMessage(), null); } break; default: final String errMessage = new String(webResponse.getBody()); Logger.e(TAG, "Server response", errMessage, ADALError.SERVER_ERROR); result = new AuthenticationResult(String.valueOf(webResponse.getStatusCode()), errMessage, null); } if (correlationIdInHeader != null && !correlationIdInHeader.isEmpty()) { try { UUID correlation = UUID.fromString(correlationIdInHeader); if (!correlation.equals(mRequest.getCorrelationId())) { Logger.w(TAG, "CorrelationId is not matching", "", ADALError.CORRELATION_ID_NOT_MATCHING_REQUEST_RESPONSE); } Logger.v(TAG, "Response correlationId:" + correlationIdInHeader); } catch (IllegalArgumentException ex) { Logger.e(TAG, "Wrong format of the correlation ID:" + correlationIdInHeader, "", ADALError.CORRELATION_ID_FORMAT, ex); } } return result; }

Target:
private AuthenticationResult processTokenResponse(HttpWebResponse webResponse) { AuthenticationResult result; String correlationIdInHeader = null; if (webResponse.getResponseHeaders() != null && webResponse.getResponseHeaders().containsKey( AuthenticationConstants.AAD.CLIENT_REQUEST_ID)) { List<String> listOfHeaders = webResponse.getResponseHeaders().get( AuthenticationConstants.AAD.CLIENT_REQUEST_ID); if (listOfHeaders != null && listOfHeaders.size() > 0) { correlationIdInHeader = listOfHeaders.get(0); } } final int statusCode = webResponse.getStatusCode(); switch (statusCode) { case HttpURLConnection.HTTP_OK: case HttpURLConnection.HTTP_BAD_REQUEST: case HttpURLConnection.HTTP_UNAUTHORIZED: try { result = parseJsonResponse(webResponse.getBody()); } catch (final JSONException jsonException) { Logger.e(TAG, jsonException.getMessage(), "", ADALError.SERVER_INVALID_JSON_RESPONSE, jsonException); result = new AuthenticationResult(JSON_PARSING_ERROR, jsonException.getMessage(), null); } break; default: final String errMessage = new String(webResponse.getBody()); Logger.e(TAG, "Server response", errMessage, ADALError.SERVER_ERROR); result = new AuthenticationResult(String.valueOf(webResponse.getStatusCode()), errMessage, null); } if (correlationIdInHeader != null && !correlationIdInHeader.isEmpty()) { try { UUID correlation = UUID.fromString(correlationIdInHeader); if (!correlation.equals(mRequest.getCorrelationId())) { Logger.w(TAG, "CorrelationId is not matching", "", ADALError.CORRELATION_ID_NOT_MATCHING_REQUEST_RESPONSE); } Logger.v(TAG, "Response correlationId:" + correlationIdInHeader); } catch (IllegalArgumentException ex) { Logger.e(TAG, "Wrong format of the correlation ID:" + correlationIdInHeader, "", ADALError.CORRELATION_ID_FORMAT, ex); } } return result; }