Skip to content
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 @@ -161,7 +161,16 @@ public void onNext(CopyContainerResponseProto chunk) {
try {
chunk.getData().writeTo(stream);
} catch (IOException e) {
response.completeExceptionally(e);
LOG.error("Failed to write the stream buffer to {} for container {}",
outputPath, containerId, e);
try {
stream.close();
} catch (IOException ex) {
LOG.error("Failed to close OutputStream {}", outputPath, e);
} finally {
deleteOutputOnFailure();
response.completeExceptionally(e);
}
}
}

Expand All @@ -176,6 +185,7 @@ public void onError(Throwable throwable) {
} catch (IOException e) {
LOG.error("Failed to close {} for container {}",
outputPath, containerId, e);
deleteOutputOnFailure();
response.completeExceptionally(e);
}
}
Expand All @@ -189,9 +199,9 @@ public void onCompleted() {
} catch (IOException e) {
LOG.error("Downloaded container {} OK, but failed to close {}",
containerId, outputPath, e);
deleteOutputOnFailure();
response.completeExceptionally(e);
}

}

private void deleteOutputOnFailure() {
Expand All @@ -204,5 +214,4 @@ private void deleteOutputOnFailure() {
}
}
}

}