Skip to content

Commit ad9728e

Browse files
justinlin-linkedinjsjtzyy
authored andcommitted
Fix the refCnt exception (#1362)
Fix the concurrency issue that causes release to be called for the object twice.
1 parent 009b646 commit ad9728e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ambry-router/src/main/java/com.github.ambry.router/GetBlobOperation.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,6 @@ private void maybeWriteToChannel() {
433433
*/
434434
void completeRead() {
435435
if (readIntoCallbackCalled.compareAndSet(false, true)) {
436-
chunkIndexToResponseInfo.values().forEach(ResponseInfo::release);
437-
chunkIndexToResponseInfo.clear();
438436
Exception e = operationException.get();
439437
readIntoFuture.done(bytesWritten.get(), e);
440438
if (readIntoCallback != null) {
@@ -451,6 +449,12 @@ void completeRead() {
451449
} else {
452450
routerMetrics.getBlobOperationTotalTimeMs.update(totalTime);
453451
}
452+
for (Integer key : chunkIndexToResponseInfo.keySet()) {
453+
ResponseInfo response = chunkIndexToResponseInfo.remove(key);
454+
if (response != null) {
455+
response.release();
456+
}
457+
}
454458
}
455459
operationCompleted = true;
456460
}

0 commit comments

Comments
 (0)