diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 00dd205a215..97b7ee4df5d 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -316,6 +316,8 @@ Release 2.8.0 - UNRELEASED YARN-3343. Increased TestCapacitySchedulerNodeLabelUpdate#testNodeUpdate timeout. (Rohith Sharmaks via jianhe) + YARN-3582. NPE in WebAppProxyServlet. (jian he via xgong) + Release 2.7.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java index fd98c80592d..d45beb68d77 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java @@ -248,8 +248,11 @@ public class WebAppProxyServlet extends HttpServlet { final String remoteUser = req.getRemoteUser(); final String pathInfo = req.getPathInfo(); - String[] parts = pathInfo.split("/", 3); - if(parts.length < 2) { + String[] parts = null; + if (pathInfo != null) { + parts = pathInfo.split("/", 3); + } + if(parts == null || parts.length < 2) { LOG.warn("{} gave an invalid proxy path {}", remoteUser, pathInfo); notFound(resp, "Your path appears to be formatted incorrectly."); return; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/TestWebAppProxyServlet.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/TestWebAppProxyServlet.java index aa6d918bcb1..2a2ca2ca3d2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/TestWebAppProxyServlet.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/TestWebAppProxyServlet.java @@ -131,6 +131,13 @@ public class TestWebAppProxyServlet { // wrong url try { + // wrong url without app ID + URL emptyUrl = new URL("http://localhost:" + proxyPort + "/proxy"); + HttpURLConnection emptyProxyConn = (HttpURLConnection) emptyUrl + .openConnection(); + emptyProxyConn.connect();; + assertEquals(HttpURLConnection.HTTP_NOT_FOUND, emptyProxyConn.getResponseCode()); + // wrong url. Set wrong app ID URL wrongUrl = new URL("http://localhost:" + proxyPort + "/proxy/app"); HttpURLConnection proxyConn = (HttpURLConnection) wrongUrl