From 9a79b738c582bd84727831987b845535625d75fe Mon Sep 17 00:00:00 2001 From: Li Lu Date: Thu, 10 Mar 2016 11:38:31 -0800 Subject: [PATCH] HADOOP-12906. AuthenticatedURL should convert a 404/Not Found into an FileNotFoundException. (Steve Loughran via gtcarrera9) --- .../authentication/client/AuthenticatedURL.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/client/AuthenticatedURL.java b/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/client/AuthenticatedURL.java index c50a5164a5..f87d9d8d5a 100644 --- a/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/client/AuthenticatedURL.java +++ b/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/client/AuthenticatedURL.java @@ -15,6 +15,7 @@ import org.apache.hadoop.security.authentication.server.AuthenticationFilter; +import java.io.FileNotFoundException; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; @@ -269,10 +270,15 @@ public static void extractToken(HttpURLConnection conn, Token token) throws IOEx } } } + } else if (respCode == HttpURLConnection.HTTP_NOT_FOUND) { + token.set(null); + throw new FileNotFoundException(conn.getURL().toString()); } else { token.set(null); - throw new AuthenticationException("Authentication failed, status: " + conn.getResponseCode() + - ", message: " + conn.getResponseMessage()); + throw new AuthenticationException("Authentication failed" + + ", URL: " + conn.getURL() + + ", status: " + conn.getResponseCode() + + ", message: " + conn.getResponseMessage()); } }