From ce6f55f9dfe7374eeb2cd3881fb4f92bbd1d03de Mon Sep 17 00:00:00 2001 From: Wouter Bancken Date: Wed, 30 Sep 2015 13:29:01 +0200 Subject: [PATCH] Add initialized boolean to ServletHolder Signed-off-by: wouter.bancken@aca-it.be --- .../eclipse/jetty/servlet/ServletHolder.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) 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 8f28e6e99b7..5a0c5c8a1fe 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 @@ -75,6 +75,7 @@ public class ServletHolder extends Holder implements UserIdentity.Scope private static final Logger LOG = Log.getLogger(ServletHolder.class); private int _initOrder = -1; private boolean _initOnStartup=false; + private boolean initialized = false; private Map _roleMap; private String _forcedPath; private String _runAsRole; @@ -83,7 +84,6 @@ public class ServletHolder extends Holder implements UserIdentity.Scope private ServletRegistration.Dynamic _registration; private JspContainer _jspContainer; - private transient Servlet _servlet; private transient Config _config; private transient long _unavailable; @@ -378,7 +378,7 @@ public class ServletHolder extends Holder implements UserIdentity.Scope if (_class!=null && javax.servlet.SingleThreadModel.class.isAssignableFrom(_class)) _servlet = new SingleThreadedWrapper(); - + } @@ -387,21 +387,24 @@ public class ServletHolder extends Holder implements UserIdentity.Scope public void initialize () throws Exception { - super.initialize(); - if (_extInstance || _initOnStartup) - { - try + if(!initialized){ + super.initialize(); + if (_extInstance || _initOnStartup) { - initServlet(); - } - catch(Exception e) - { - if (_servletHandler.isStartWithUnavailable()) - LOG.ignore(e); - else - throw e; + try + { + initServlet(); + } + catch(Exception e) + { + if (_servletHandler.isStartWithUnavailable()) + LOG.ignore(e); + else + throw e; + } } } + initialized = true; }