fixed reset of DispatcherType

This commit is contained in:
Greg Wilkins 2015-10-30 10:35:37 +11:00
parent 915a905df4
commit fa53b11850
2 changed files with 34 additions and 11 deletions

View File

@ -29,6 +29,7 @@ import java.nio.channels.ClosedChannelException;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import javax.servlet.DispatcherType; import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher; import javax.servlet.RequestDispatcher;
@ -264,6 +265,8 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
handle(); handle();
} }
AtomicReference<Action> caller = new AtomicReference<>();
/** /**
* @return True if the channel is ready to continue handling (ie it is not suspended) * @return True if the channel is ready to continue handling (ie it is not suspended)
*/ */
@ -297,7 +300,6 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
throw new IllegalStateException("state=" + _state); throw new IllegalStateException("state=" + _state);
_request.setHandled(false); _request.setHandled(false);
_response.getHttpOutput().reopen(); _response.getHttpOutput().reopen();
_request.setDispatcherType(DispatcherType.REQUEST);
List<HttpConfiguration.Customizer> customizers = _configuration.getCustomizers(); List<HttpConfiguration.Customizer> customizers = _configuration.getCustomizers();
if (!customizers.isEmpty()) if (!customizers.isEmpty())
@ -305,7 +307,15 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
for (HttpConfiguration.Customizer customizer : customizers) for (HttpConfiguration.Customizer customizer : customizers)
customizer.customize(getConnector(), _configuration, _request); customizer.customize(getConnector(), _configuration, _request);
} }
getServer().handle(this); try
{
_request.setDispatcherType(DispatcherType.REQUEST);
getServer().handle(this);
}
finally
{
_request.setDispatcherType(null);
}
break; break;
} }
@ -313,8 +323,16 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
{ {
_request.setHandled(false); _request.setHandled(false);
_response.getHttpOutput().reopen(); _response.getHttpOutput().reopen();
_request.setDispatcherType(DispatcherType.ASYNC);
getServer().handleAsync(this); try
{
_request.setDispatcherType(DispatcherType.ASYNC);
getServer().handleAsync(this);
}
finally
{
_request.setDispatcherType(null);
}
break; break;
} }
@ -336,8 +354,16 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
_request.setAttribute(ERROR_STATUS_CODE,code); _request.setAttribute(ERROR_STATUS_CODE,code);
_request.setHandled(false); _request.setHandled(false);
_response.getHttpOutput().reopen(); _response.getHttpOutput().reopen();
_request.setDispatcherType(DispatcherType.ERROR);
getServer().handle(this); try
{
_request.setDispatcherType(DispatcherType.ERROR);
getServer().handle(this);
}
finally
{
_request.setDispatcherType(null);
}
} }
break; break;
} }
@ -390,10 +416,6 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
else else
handleException(failure); handleException(failure);
} }
finally
{
_request.setDispatcherType(null);
}
action = _state.unhandle(); action = _state.unhandle();
} }

View File

@ -40,6 +40,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentLinkedQueue;
import javax.servlet.AsyncContext; import javax.servlet.AsyncContext;
import javax.servlet.AsyncListener; import javax.servlet.AsyncListener;
@ -1754,7 +1755,7 @@ public class Request implements HttpServletRequest
* @param request the Request metadata * @param request the Request metadata
*/ */
public void setMetaData(org.eclipse.jetty.http.MetaData.Request request) public void setMetaData(org.eclipse.jetty.http.MetaData.Request request)
{ {
_metadata=request; _metadata=request;
_originalURI=_metadata.getURIString(); _originalURI=_metadata.getURIString();
setMethod(request.getMethod()); setMethod(request.getMethod());