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 ba2c64f424db08..f2c65353266735 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 @@ -106,7 +106,7 @@ URLConnection connect( // The read timeout is always large because it stays in effect after this method. connection.setReadTimeout(READ_TIMEOUT_MS); // Java tries to abstract HTTP error responses for us. We don't want that. So we're going - // to try and undo any IOException that doesn't appepar to be a legitimate I/O exception. + // to try and undo any IOException that doesn't appear to be a legitimate I/O exception. int code; try { connection.connect(); @@ -121,6 +121,12 @@ URLConnection connect( // 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")) { throw e; }