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

Swallow exception from close call when there is an underlying IOException #333

Merged
merged 2 commits into from
Nov 7, 2016
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 @@ -75,10 +75,21 @@ public LowLevelHttpResponse execute() throws IOException {
connection.setChunkedStreamingMode(0);
}
OutputStream out = connection.getOutputStream();
boolean threw = true;
try {
getStreamingContent().writeTo(out);
threw = false;
} finally {
out.close();
try {
out.close();
} catch (IOException exception) {
// When writeTo() throws an exception, chances are that the close call will also fail.
// In such case, swallow exception from close call so that the underlying cause can
// propagate.
if (!threw) {
throw exception;
}
}
}
} else {
// cannot call setDoOutput(true) because it would change a GET method to POST
Expand Down