diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/kms/KMSClientProvider.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/kms/KMSClientProvider.java index 11815da9d2..8125510a72 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/kms/KMSClientProvider.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/kms/KMSClientProvider.java @@ -56,6 +56,7 @@ import java.io.OutputStreamWriter; import java.io.Writer; import java.lang.reflect.UndeclaredThrowableException; +import java.net.ConnectException; import java.net.HttpURLConnection; import java.net.InetSocketAddress; import java.net.MalformedURLException; @@ -478,10 +479,14 @@ public HttpURLConnection run() throws Exception { return authUrl.openConnection(url, authToken, doAsUser); } }); + } catch (ConnectException ex) { + String msg = "Failed to connect to: " + url.toString(); + LOG.warn(msg); + throw new IOException(msg, ex); + } catch (SocketTimeoutException ex) { + LOG.warn("Failed to connect to {}:{}", url.getHost(), url.getPort()); + throw ex; } catch (IOException ex) { - if (ex instanceof SocketTimeoutException) { - LOG.warn("Failed to connect to {}:{}", url.getHost(), url.getPort()); - } throw ex; } catch (UndeclaredThrowableException ex) { throw new IOException(ex.getUndeclaredThrowable());