diff options
author | 2017-07-31 21:38:18 +0200 | |
---|---|---|
committer | 2017-08-01 12:21:54 +0200 | |
commit | 945171410960890311eac191fd5c87ecd3c1b9b8 (patch) | |
tree | 81f65d95800c750bcd39e53825114e06b8a7eed3 /src/main/java/com/google/devtools/build | |
parent | de965ac47e5dedf9dd43004d7523dbfa5ab64de1 (diff) |
Allow IOExceptions with null messages to propogate.
I noticed that one of the exceptions that causes #2470 is
SocketTimeoutException. The outer exception handlers of
HttpConnector.connect have logic to handle such an exception, so just
let them propagate.
Change-Id: Ic87b678431178e296f14f1be34acf8024ddbfc19
PiperOrigin-RevId: 163732268
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnector.java | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnector.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnector.java index f2c6535326..dacd93ae08 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnector.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnector.java @@ -121,13 +121,10 @@ class HttpConnector { // This will happen if the user does something like specify a port greater than 2^16-1. throw new UnrecoverableHttpException(e.getMessage()); } catch (IOException e) { - // I'm not sure in what cases this happens, but IOException can be thrown with a null - // message. - if (e.getMessage() == null) { - throw new UnrecoverableHttpException( - "Failed to even get an error message from " + url); - } - if (!e.getMessage().startsWith("Server returned")) { + // Some HTTP error status codes are converted to IOExceptions, which we can only + // disambiguate from other IOExceptions by checking the exception message. We need to be + // careful because some exceptions (e.g., SocketTimeoutException) may have a null message. + if (e.getMessage() == null || !e.getMessage().startsWith("Server returned")) { throw e; } code = connection.getResponseCode(); |