From 9b9771d77d6036d97efa5522f467cef3a8626551 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 23 Jan 2020 07:53:56 +1000 Subject: [PATCH] spec addJspFile javadoc expect IllegalArgumentException if name is null or empty string (#4510) * spec javadoc expect IllegalArgumentException if name is null or empty string Signed-off-by: olivier lamy --- .../java/org/eclipse/jetty/servlet/ServletContextHandler.java | 2 +- .../org/eclipse/jetty/servlet/ServletContextHandlerTest.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java index c6fb838c3ce..e93bfa96fbf 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java @@ -1078,7 +1078,7 @@ public class ServletContextHandler extends ContextHandler throw new IllegalStateException(); if (StringUtil.isBlank(name)) - throw new IllegalStateException("Missing name"); + throw new IllegalArgumentException("Missing name"); if (!_enabled) throw new UnsupportedOperationException(); diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java index 80a46a25106..50951d13bdd 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletContextHandlerTest.java @@ -1028,6 +1028,9 @@ public class ServletContextHandlerTest } } + assertThrows(IllegalArgumentException.class, () -> root.getServletContext().addJspFile(null, "/path/to/some.jsp")); + assertThrows(IllegalArgumentException.class, () -> root.getServletContext().addJspFile("", "/path/to/some.jsp")); + root.addBean(new MySCIStarter(root.getServletContext(), new JSPAddingSCI()), true); _server.start(); MappedResource mappedServlet = root.getServletHandler().getMappedServlet("/somejsp/xxx");