[go: nahoru, domu]

Skip to content

Commit

Permalink
Swallow exception from close call when there is an underlying IOExcep…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
chajath authored and ejona86 committed Nov 7, 2016
1 parent 49da636 commit 75c2b20
Showing 1 changed file with 12 additions and 1 deletion.
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

0 comments on commit 75c2b20

Please sign in to comment.