Source:
private void testResponseDeserializationError(OperationHelper opHelper, NetworkClient networkClient, String blobId) throws Exception { mockSelectorState.set(MockSelectorState.Good); FutureResult futureResult = opHelper.submitOperation(blobId); int requestParallelism = opHelper.requestParallelism; List<RequestInfo> allRequests = new ArrayList<>(); long loopStartTimeMs = SystemTime.getInstance().milliseconds(); while (allRequests.size() < requestParallelism) { if (loopStartTimeMs + AWAIT_TIMEOUT_MS < SystemTime.getInstance().milliseconds()) { Assert.fail("Waited too long for requests."); } opHelper.pollOpManager(allRequests); } List<ResponseInfo> responseInfoList = new ArrayList<>(); loopStartTimeMs = SystemTime.getInstance().milliseconds(); do { if (loopStartTimeMs + AWAIT_TIMEOUT_MS < SystemTime.getInstance().milliseconds()) { Assert.fail("Waited too long for the response."); } responseInfoList.addAll(networkClient.sendAndPoll(allRequests, 10)); allRequests.clear(); } while (responseInfoList.size() < requestParallelism); ByteBuffer response = responseInfoList.get(0).getResponse(); byte b = response.get(response.limit() - 1); response.put(response.limit() - 1, (byte) ~b); for (ResponseInfo responseInfo : responseInfoList) { opHelper.handleResponse(responseInfo); } allRequests.clear(); if (testEncryption) { awaitOpCompletionOrTimeOut(opHelper, futureResult); } else { opHelper.pollOpManager(allRequests); } try { futureResult.get(AWAIT_TIMEOUT_MS, TimeUnit.MILLISECONDS); } catch (ExecutionException e) { Assert.fail("Operation should have succeeded with one corrupt response"); } }

Target:
private void testResponseDeserializationError(OperationHelper opHelper, NetworkClient networkClient, String blobId) throws Exception { mockSelectorState.set(MockSelectorState.Good); FutureResult futureResult = opHelper.submitOperation(blobId); int requestParallelism = opHelper.requestParallelism; List<RequestInfo> allRequests = new ArrayList<>(); long loopStartTimeMs = SystemTime.getInstance().milliseconds(); while (allRequests.size() < requestParallelism) { if (loopStartTimeMs + AWAIT_TIMEOUT_MS < SystemTime.getInstance().milliseconds()) { Assert.fail("Waited too long for requests."); } opHelper.pollOpManager(allRequests); } List<ResponseInfo> responseInfoList = new ArrayList<>(); loopStartTimeMs = SystemTime.getInstance().milliseconds(); do { if (loopStartTimeMs + AWAIT_TIMEOUT_MS < SystemTime.getInstance().milliseconds()) { Assert.fail("Waited too long for the response."); } responseInfoList.addAll(networkClient.sendAndPoll(allRequests, 10)); allRequests.clear(); } while (responseInfoList.size() < requestParallelism); ByteBuffer response = responseInfoList.get(0).getResponse(); byte b = response.get(response.limit() - 1); response.put(response.limit() - 1, (byte) ~b); for (ResponseInfo responseInfo : responseInfoList) { opHelper.handleResponse(responseInfo); } allRequests.clear(); if (testEncryption) { opHelper.awaitOpCompletionOrTimeOut(futureResult); } else { opHelper.pollOpManager(allRequests); } try { futureResult.get(AWAIT_TIMEOUT_MS, TimeUnit.MILLISECONDS); } catch (ExecutionException e) { Assert.fail("Operation should have succeeded with one corrupt response"); } }