Skip to content

Commit

Permalink
chore: attempt to drain gRPC ReadObject stream iterator
Browse files Browse the repository at this point in the history
Related #2696
  • Loading branch information
BenWhitehead committed Sep 10, 2024
1 parent 96e4049 commit d0ffc84
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public boolean hasNext() {
if (!result.isDone()) {
result.setException(StorageException.coalesce(e));
}
reset();
throw e;
}
}
Expand All @@ -194,6 +195,7 @@ public ReadObjectResponse next() {
if (!result.isDone()) {
result.setException(StorageException.coalesce(e));
}
reset();
throw e;
}
}
Expand All @@ -212,7 +214,7 @@ public void close() {
} catch (IOException e) {
if (ioException == null) {
ioException = e;
} else {
} else if (ioException != e) {
ioException.addSuppressed(e);
}
}
Expand All @@ -238,5 +240,11 @@ private Iterator<ReadObjectResponse> ensureResponseIteratorOpen() {
}
}
}

private void reset() {
serverStream = null;
responseIterator = null;
streamInitialized = false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ static void closeAllStreams(Iterable<InputStream> inputStreams) throws IOExcepti
} catch (IOException e) {
if (ioException == null) {
ioException = e;
} else {
} else if (ioException != e) {
ioException.addSuppressed(e);
}
}
Expand Down

0 comments on commit d0ffc84

Please sign in to comment.