458175 multipart annotation on lazily loaded servlet does not work

This commit is contained in:
Jan Bartel 2015-01-23 13:58:42 +01:00
parent b02f283971
commit ae47edb8a7
1 changed files with 18 additions and 10 deletions

View File

@ -745,10 +745,27 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
protected void prepare (Request baseRequest, ServletRequest request, ServletResponse response)
throws ServletException, UnavailableException
{
ensureInstance();
MultipartConfigElement mpce = ((Registration)getRegistration()).getMultipartConfig();
if (mpce != null)
baseRequest.setAttribute(Request.__MULTIPART_CONFIG_ELEMENT, mpce);
}
public synchronized Servlet ensureInstance()
throws ServletException, UnavailableException
{
if (_class==null)
throw new UnavailableException("Servlet Not Initialized");
Servlet servlet=_servlet;
if (!isStarted())
throw new UnavailableException("Servlet not initialized", -1);
if (_unavailable!=0 || (!_initOnStartup && servlet==null))
servlet=getServlet();
if (servlet==null)
throw new UnavailableException("Could not instantiate "+_class);
return servlet;
}
/* ------------------------------------------------------------ */
/** Service a request with this servlet.
@ -769,16 +786,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
if (_class==null)
throw new UnavailableException("Servlet Not Initialized");
Servlet servlet=_servlet;
synchronized(this)
{
if (!isStarted())
throw new UnavailableException("Servlet not initialized", -1);
if (_unavailable!=0 || (!_initOnStartup && servlet==null))
servlet=getServlet();
if (servlet==null)
throw new UnavailableException("Could not instantiate "+_class);
}
Servlet servlet = ensureInstance();
// Service the request
boolean servlet_error=true;