Skip to content

Commit

Permalink
Fix a bug in ResponseInfo.release (#1330)
Browse files Browse the repository at this point in the history
Increment numChunksWrittenOut before releasing the responseInfo might end up another thread calling completeRead at the same time. We might see the same ResponseInfo being released twice.
  • Loading branch information
justinlin-linkedin authored and zzmao committed Dec 6, 2019
1 parent ca1c9be commit 6e43fda
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,12 @@ public void onCompletion(Long result, Exception exception) {
if (exception != null) {
setOperationException(exception);
}
int currentNumChunk = numChunksWrittenOut.getAndIncrement();
int currentNumChunk = numChunksWrittenOut.get();
ResponseInfo responseInfo = chunkIndexToResponseInfo.remove(currentNumChunk);
if (responseInfo != null) {
responseInfo.release();
}
numChunksWrittenOut.incrementAndGet();
routerCallback.onPollReady();
}
};
Expand Down

0 comments on commit 6e43fda

Please sign in to comment.