407931 Add toggle for failing on servlet availability

This commit is contained in:
Jan Bartel 2013-05-16 08:25:46 +10:00
parent 76d4859eda
commit 9c168866ff
3 changed files with 22 additions and 7 deletions

View File

@ -104,8 +104,8 @@ public class Holder<T> extends AbstractLifeCycle implements Dumpable
{
//if no class already loaded and no classname, make servlet permanently unavailable
if (_class==null && (_className==null || _className.equals("")))
throw new UnavailableException("No class for Servlet or Filter for "+_name, -1);
throw new UnavailableException("No class for Servlet or Filter for "+_name);
//try to load class
if (_class==null)
{
@ -118,7 +118,7 @@ public class Holder<T> extends AbstractLifeCycle implements Dumpable
catch (Exception e)
{
LOG.warn(e);
throw new UnavailableException(e.getMessage(), -1);
throw new UnavailableException(e.getMessage());
}
}
}

View File

@ -102,7 +102,7 @@ public class ServletHandler extends ScopedHandler
private int _matchAfterIndex = -1; //index of 1st programmatic FilterMapping with isMatchAfter=true
private boolean _filterChainsCached=true;
private int _maxFilterChainsCacheSize=512;
private boolean _startWithUnavailable=true;
private boolean _startWithUnavailable=false;
private IdentityService _identityService;
private ServletHolder[] _servlets=new ServletHolder[0];

View File

@ -288,6 +288,8 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
_unavailable=0;
if (!_enabled)
return;
//check servlet has a class (ie is not a preliminary registration). If preliminary, fail startup.
try
{
@ -296,9 +298,17 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
catch (UnavailableException ue)
{
makeUnavailable(ue);
throw ue;
if (_servletHandler.isStartWithUnavailable())
{
LOG.ignore(ue);
return;
}
else
throw ue;
}
//servlet is not an instance of javax.servlet.Servlet
try
{
checkServletType();
@ -306,8 +316,13 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
catch (UnavailableException ue)
{
makeUnavailable(ue);
if (!_servletHandler.isStartWithUnavailable())
throw ue; //servlet is not an instance of javax.servlet.Servlet
if (_servletHandler.isStartWithUnavailable())
{
LOG.ignore(ue);
return;
}
else
throw ue;
}