Fix possible NPEs when reporting transport errors

There was a bug in JGit which caused NPEs being thrown when Transport
errors should be reported. Avoid the NPE to let the original error show
up.

Change-Id: I9e1e2b0195bd61b7e531a09d0fc7bce109bd6515
This commit is contained in:
Christian Halstrick 2016-04-27 09:47:28 +02:00
parent 22d7ec2971
commit ddc0e9e84a
1 changed files with 4 additions and 2 deletions

View File

@ -189,7 +189,8 @@ public static int response(final HttpConnection c) throws IOException {
try {
return c.getResponseCode();
} catch (ConnectException ce) {
final String host = c.getURL().getHost();
final URL url = c.getURL();
final String host = (url == null) ? "<null>" : url.getHost();
// The standard J2SE error message is not very useful.
//
if ("Connection timed out: connect".equals(ce.getMessage())) //$NON-NLS-1$
@ -216,7 +217,8 @@ public static int response(final java.net.HttpURLConnection c)
try {
return c.getResponseCode();
} catch (ConnectException ce) {
final String host = c.getURL().getHost();
final URL url = c.getURL();
final String host = (url == null) ? "<null>" : url.getHost();
// The standard J2SE error message is not very useful.
//
if ("Connection timed out: connect".equals(ce.getMessage())) //$NON-NLS-1$