Source:
<code>private void getAndAssertSuccess(final boolean getChunksBeforeRead, final CountDownLatch readIntoLatch) throws Exception { final CountDownLatch readCompleteLatch = new CountDownLatch(1); final AtomicReference<Exception> readCompleteException = new AtomicReference<>(null); final AtomicLong readCompleteResult = new AtomicLong(0); final AtomicReference<Exception> operationException = new AtomicReference<>(null); final int numChunks = ((blobSize + maxChunkSize - 1) / maxChunkSize) + (blobSize > maxChunkSize ? 1 : 0); mockNetworkClient.resetProcessedResponseCount(); Callback<ReadableStreamChannel> callback = new Callback<ReadableStreamChannel>() { @Override public void onCompletion(final ReadableStreamChannel result, final Exception exception) { if (exception != null) { operationException.set(exception); readCompleteLatch.countDown(); } else { Utils.newThread(new Runnable() { @Override public void run() { if (getChunksBeforeRead) { try { <START> while (mockNetworkClient.getProcessedResponseCount() < numChunks * 2) { <END> Thread.sleep(10); } } catch (InterruptedException ignored) { } } assertSuccess(result, readCompleteLatch, readCompleteResult, readCompleteException, readIntoLatch); } }, false).start(); } } }; GetBlobOperation op = createOperationAndComplete(callback); readCompleteLatch.await(); Assert.assertTrue("Operation should be complete at this time", op.isOperationComplete()); if (operationException.get() != null) { throw operationException.get(); } if (readCompleteException.get() != null) { throw readCompleteException.get(); } Assert.assertEquals("Size read must equal size written", blobSize, readCompleteResult.get()); }</code><technical_language>s/2/routerConfig.routerGetRequestParallelism</technical_language>

Target:
private void getAndAssertSuccess(final boolean getChunksBeforeRead, final CountDownLatch readIntoLatch) throws Exception { final CountDownLatch readCompleteLatch = new CountDownLatch(1); final AtomicReference<Exception> readCompleteException = new AtomicReference<>(null); final AtomicLong readCompleteResult = new AtomicLong(0); final AtomicReference<Exception> operationException = new AtomicReference<>(null); final int numChunks = ((blobSize + maxChunkSize - 1) / maxChunkSize) + (blobSize > maxChunkSize ? 1 : 0); mockNetworkClient.resetProcessedResponseCount(); Callback<ReadableStreamChannel> callback = new Callback<ReadableStreamChannel>() { @Override public void onCompletion(final ReadableStreamChannel result, final Exception exception) { if (exception != null) { operationException.set(exception); readCompleteLatch.countDown(); } else { Utils.newThread(new Runnable() { @Override public void run() { if (getChunksBeforeRead) { try { while (mockNetworkClient.getProcessedResponseCount() < numChunks * routerConfig.routerGetRequestParallelism) { Thread.sleep(10); } } catch (InterruptedException ignored) { } } assertSuccess(result, readCompleteLatch, readCompleteResult, readCompleteException, readIntoLatch); } }, false).start(); } } }; GetBlobOperation op = createOperationAndComplete(callback); readCompleteLatch.await(); Assert.assertTrue("Operation should be complete at this time", op.isOperationComplete()); if (operationException.get() != null) { throw operationException.get(); } if (readCompleteException.get() != null) { throw readCompleteException.get(); } Assert.assertEquals("Size read must equal size written", blobSize, readCompleteResult.get()); }