diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java index 6de3b7e48bf..1e50dd1249d 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java @@ -71,7 +71,7 @@ public class ServletHolder extends Holder implements UserIdentity.Scope private static final Logger LOG = Log.getLogger(ServletHolder.class); /* ---------------------------------------------------------------- */ - private int _initOrder; + private int _initOrder = -1; private boolean _initOnStartup=false; private Map _roleMap; private String _forcedPath; @@ -179,7 +179,7 @@ public class ServletHolder extends Holder implements UserIdentity.Scope */ public void setInitOrder(int order) { - _initOnStartup=order>0; + _initOnStartup=order>=0; _initOrder = order; } @@ -329,7 +329,6 @@ public class ServletHolder extends Holder implements UserIdentity.Scope throws Exception { super.initialize(); - if (_extInstance || _initOnStartup) { try 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 4c06368b4bd..b923e53d8cb 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 @@ -130,8 +130,8 @@ public class ServletContextHandlerTest holder0.setInitOrder(0); _server.start(); - assertEquals(2,__testServlets.get()); - assertThat(holder0.getServletInstance(),nullValue()); + assertEquals(3,__testServlets.get()); + assertThat(holder0.getServletInstance(),notNullValue(Servlet.class)); _server.stop(); assertEquals(0,__testServlets.get());