Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix additional release bug #1367

Merged
merged 2 commits into from
Jan 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,7 @@ public boolean isOpen() {
@Override
public void close() throws IOException {
if (isOpen.compareAndSet(true, false)) {
chunkIndexToResponseInfo.values().forEach(ResponseInfo::release);
chunkIndexToResponseInfo.clear();
releaseResource();
if (numChunksWrittenOut.get() != numChunksTotal) {
setOperationException(new RouterException(
"The ReadableStreamChannel for blob data has been closed by the user before all chunks were written out.",
Expand Down Expand Up @@ -449,16 +448,24 @@ void completeRead() {
} else {
routerMetrics.getBlobOperationTotalTimeMs.update(totalTime);
}
for (Integer key : chunkIndexToResponseInfo.keySet()) {
ResponseInfo response = chunkIndexToResponseInfo.remove(key);
if (response != null) {
response.release();
}
}
releaseResource();
}
operationCompleted = true;
}

/**
* Release all the {@link ResponseInfo} in the map. Use {@link ConcurrentHashMap#remove(Object)} method to avoid
* conflict with the release call in the chunk async callback.
*/
private void releaseResource() {
for (Integer key : chunkIndexToResponseInfo.keySet()) {
ResponseInfo response = chunkIndexToResponseInfo.remove(key);
if (response != null) {
response.release();
}
}
}

/**
* Update chunking and size related metrics - blob size, chunk count, and whether the blob is simple or composite.
*/
Expand Down