Index: org/apache/catalina/core/LocalStrings.properties =================================================================== --- org/apache/catalina/core/LocalStrings.properties (revision 1429490) +++ org/apache/catalina/core/LocalStrings.properties (working copy) @@ -21,6 +21,8 @@ applicationContext.addRole.ise=Roles can not be added to context {0} as the context has been initialised applicationContext.addServlet.ise=Servlets can not be added to context {0} as the context has been initialised applicationContext.attributeEvent=Exception thrown by attributes event listener +applicationContext.invalidFilterName=Unable to add filter definition due to invalid filter name [{0}]. +applicationContext.invalidServletName=Unable to add servlet definition due to invalid servlet name [{0}]. applicationContext.mapping.error=Error during mapping applicationContext.requestDispatcher.iae=Path {0} does not start with a "/" character applicationContext.resourcePaths.iae=Path {0} does not start with a "/" character Index: org/apache/catalina/core/ApplicationContext.java =================================================================== --- org/apache/catalina/core/ApplicationContext.java (revision 1429490) +++ org/apache/catalina/core/ApplicationContext.java (working copy) @@ -943,7 +943,12 @@ private FilterRegistration.Dynamic addFilter(String filterName, String filterClass, Filter filter) throws IllegalStateException { - + + if (filterName == null || filterName.equals("")) { + throw new IllegalArgumentException( + sm.getString("applicationContext.invalidFilterName", filterName)); + } + if (!context.getState().equals(LifecycleState.STARTING_PREP)) { //TODO Spec breaking enhancement to ignore this restriction throw new IllegalStateException( @@ -1083,7 +1088,12 @@ private ServletRegistration.Dynamic addServlet(String servletName, String servletClass, Servlet servlet) throws IllegalStateException { - + + if (servletName == null || servletName.equals("")) { + throw new IllegalArgumentException( + sm.getString("applicationContext.invalidServletName", servletName)); + } + if (!context.getState().equals(LifecycleState.STARTING_PREP)) { //TODO Spec breaking enhancement to ignore this restriction throw new IllegalStateException( Index: org/apache/catalina/deploy/ServletDef.java =================================================================== --- org/apache/catalina/deploy/ServletDef.java (revision 1429490) +++ org/apache/catalina/deploy/ServletDef.java (working copy) @@ -25,6 +25,8 @@ import java.util.Map; import java.util.Set; +import org.apache.tomcat.util.res.StringManager; + /** * Representation of a servlet definition for a web application, as represented @@ -35,6 +37,9 @@ private static final long serialVersionUID = 1L; + private static final StringManager sm = + StringManager.getManager(Constants.Package); + // ------------------------------------------------------------- Properties @@ -104,6 +109,10 @@ } public void setServletName(String servletName) { + if (servletName == null || servletName.equals("")) { + throw new IllegalArgumentException( + sm.getString("servletDef.invalidServletName", servletName)); + } this.servletName = servletName; } Index: org/apache/catalina/deploy/LocalStrings.properties =================================================================== --- org/apache/catalina/deploy/LocalStrings.properties (revision 1429490) +++ org/apache/catalina/deploy/LocalStrings.properties (working copy) @@ -12,6 +12,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +filterDef.invalidFilterName=Invalid [{0}] in filter definition. + +servletDef.invalidServletName=Invalid [{0}] in servlet definition. webXml.duplicateEnvEntry=Duplicate env-entry name [{0}] webXml.duplicateFilter=Duplicate filter name [{0}] Index: org/apache/catalina/deploy/FilterDef.java =================================================================== --- org/apache/catalina/deploy/FilterDef.java (revision 1429490) +++ org/apache/catalina/deploy/FilterDef.java (working copy) @@ -25,6 +25,8 @@ import javax.servlet.Filter; +import org.apache.tomcat.util.res.StringManager; + /** * Representation of a filter definition for a web application, as represented @@ -38,6 +40,9 @@ private static final long serialVersionUID = 1L; + private static final StringManager sm = + StringManager.getManager(Constants.Package); + // ------------------------------------------------------------- Properties @@ -108,6 +113,10 @@ } public void setFilterName(String filterName) { + if (filterName == null || filterName.equals("")) { + throw new IllegalArgumentException( + sm.getString("filterDef.invalidFilterName", filterName)); + } this.filterName = filterName; }