402982 Premature initialization of Servlets

This commit is contained in:
Jan Bartel 2013-03-14 15:28:41 +11:00
parent c5ace89ffd
commit cd47727ce4
5 changed files with 43 additions and 3 deletions

View File

@ -97,7 +97,19 @@ public class FilterHolder extends Holder<Filter>
super.stop();
throw new IllegalStateException(msg);
}
}
/* ------------------------------------------------------------ */
@Override
public void initialize() throws Exception
{
super.initialize();
if (_filter==null)
{
try
@ -123,6 +135,7 @@ public class FilterHolder extends Holder<Filter>
_filter.init(_config);
}
/* ------------------------------------------------------------ */
@Override
public void doStop()

View File

@ -82,6 +82,19 @@ public class Holder<T> extends AbstractLifeCycle implements Dumpable
{
return _extInstance;
}
/* ------------------------------------------------------------ */
/**
* Do any setup necessary after starting
* @throws Exception
*/
public void initialize()
throws Exception
{
if (!isStarted())
throw new IllegalStateException("Not started: "+this);
}
/* ------------------------------------------------------------ */
@SuppressWarnings("unchecked")

View File

@ -741,6 +741,7 @@ public class ServletHandler extends ScopedHandler
try
{
h.start();
h.initialize();
}
catch (Exception e)
{

View File

@ -280,7 +280,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
_enabled = enabled;
}
/* ------------------------------------------------------------ */
public void doStart()
throws Exception
@ -319,7 +319,17 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
if (_class!=null && javax.servlet.SingleThreadModel.class.isAssignableFrom(_class))
_servlet = new SingleThreadedWrapper();
}
/* ------------------------------------------------------------ */
@Override
public void initialize ()
throws Exception
{
super.initialize();
if (_extInstance || _initOnStartup)
{
try
@ -335,7 +345,8 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
}
}
}
/* ------------------------------------------------------------ */
public void doStop()
throws Exception

View File

@ -98,7 +98,9 @@ public abstract class AbstractDoSFilterTest
public void startFilters() throws Exception
{
_dosFilter.start();
_dosFilter.initialize();
_timeoutFilter.start();
_timeoutFilter.initialize();
}
@After