Source:
void handleResponse(ResponseInfo responseInfo) { int correlationId = ((PutRequest) responseInfo.getRequest()).getCorrelationId(); ChunkPutRequest request = correlationIdToChunkPutRequest.remove(correlationId); if (request == null) { return; } boolean isSuccessful; if (responseInfo.getError() != null) { setChunkException(new RouterException("Operation timed out", RouterErrorCode.OperationTimedOut)); putManager.responseHandler .onRequestResponseException(request.replicaId, new IOException("NetworkClient error")); isSuccessful = false; } else { try { PutResponse putResponse = PutResponse.readFrom(new DataInputStream(new ByteBufferInputStream(responseInfo.getResponse()))); if (putResponse.getCorrelationId() != correlationId) { logger.error("The correlation id in the PutResponse " + putResponse.getCorrelationId() + " is not the same as the correlation id in the associated PutRequest: " + correlationId); setChunkException(new RouterException("Operation timed out", RouterErrorCode.UnexpectedInternalError)); isSuccessful = false; } else { putManager.responseHandler.onRequestResponseError(request.replicaId, putResponse.getError()); switch (putResponse.getError()) { case No_Error: logger.trace("The putRequest was successful"); isSuccessful = true; break; default: processServerError(putResponse.getError()); isSuccessful = false; logger.trace("Server returned an error: ", putResponse.getError()); break; } } } catch (IOException e) { isSuccessful = false; } } operationTracker.onResponse(request.replicaId, isSuccessful); completeIfDone(); }

Target:
void handleResponse(ResponseInfo responseInfo) { int correlationId = ((PutRequest) responseInfo.getRequest()).getCorrelationId(); ChunkPutRequestInfo chunkPutRequestInfo = correlationIdToChunkPutRequestInfo.remove(correlationId); if (chunkPutRequestInfo == null) { return; } boolean isSuccessful; if (responseInfo.getError() != null) { setChunkException(new RouterException("Operation timed out", RouterErrorCode.OperationTimedOut)); responseHandler .onRequestResponseException(chunkPutRequestInfo.replicaId, new IOException("NetworkClient error")); isSuccessful = false; } else { try { PutResponse putResponse = PutResponse.readFrom(new DataInputStream(new ByteBufferInputStream(responseInfo.getResponse()))); if (putResponse.getCorrelationId() != correlationId) { logger.error("The correlation id in the PutResponse " + putResponse.getCorrelationId() + " is not the same as the correlation id in the associated PutRequest: " + correlationId); setChunkException( new RouterException("Unexpected internal error", RouterErrorCode.UnexpectedInternalError)); isSuccessful = false; } else { ServerErrorCode putError = putResponse.getError(); responseHandler.onRequestResponseError(chunkPutRequestInfo.replicaId, putError); if (putError == ServerErrorCode.No_Error) { logger.trace("The putRequest was successful"); isSuccessful = true; } else { processServerError(putResponse.getError()); isSuccessful = false; logger.trace("Server returned an error: ", putResponse.getError()); } } } catch (IOException e) { setChunkException(new RouterException("Response deserialization received an unexpected error", e, RouterErrorCode.UnexpectedInternalError)); isSuccessful = false; } } operationTracker.onResponse(chunkPutRequestInfo.replicaId, isSuccessful); checkAndMaybeComplete(); }