fixed merge

This commit is contained in:
Greg Wilkins 2013-10-21 14:56:23 +11:00
parent 82a991dd07
commit ffffd3938c
2 changed files with 48 additions and 94 deletions

View File

@ -295,6 +295,14 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable
_request.setAttribute(RequestDispatcher.ERROR_REQUEST_URI,_request.getRequestURI());
_response.setStatusWithReason(500,"Async Timeout");
ErrorHandler eh = _state.getContextHandler().getErrorHandler();
if (eh instanceof ErrorHandler.ErrorPageMapper)
{
String error_page=((ErrorHandler.ErrorPageMapper)eh).getErrorPage((HttpServletRequest)_state.getAsyncContextEvent().getSuppliedRequest());
if (error_page!=null)
_state.getAsyncContextEvent().setDispatchTarget(_state.getContextHandler().getServletContext(),error_page);
}
getServer().handleAsync(this);
break;

View File

@ -18,7 +18,6 @@
package org.eclipse.jetty.servlet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -27,15 +26,10 @@ import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.server.Dispatcher;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ErrorHandler;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
/* ------------------------------------------------------------ */
/** Error Page Error Handler
@ -44,11 +38,8 @@ import org.eclipse.jetty.util.log.Logger;
* the internal ERROR style of dispatch.
*
*/
public class ErrorPageErrorHandler extends ErrorHandler
public class ErrorPageErrorHandler extends ErrorHandler implements ErrorHandler.ErrorPageMapper
{
private static final Logger LOG = Log.getLogger(ErrorPageErrorHandler.class);
public final static String ERROR_PAGE="org.eclipse.jetty.server.error_page";
public final static String GLOBAL_ERROR_PAGE = "org.eclipse.jetty.server.error_page.global";
protected ServletContext _servletContext;
@ -60,26 +51,11 @@ public class ErrorPageErrorHandler extends ErrorHandler
{}
/* ------------------------------------------------------------ */
/**
* @see org.eclipse.jetty.server.handler.ErrorHandler#handle(String, Request, HttpServletRequest, HttpServletResponse)
*/
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException
{
String method = request.getMethod();
if (!HttpMethod.GET.is(method) && !HttpMethod.POST.is(method) && !HttpMethod.HEAD.is(method))
{
baseRequest.setHandled(true);
return;
}
if (_errorPages!=null)
public String getErrorPage(HttpServletRequest request)
{
String error_page= null;
Throwable th= (Throwable)request.getAttribute(Dispatcher.ERROR_EXCEPTION);
// Walk the cause hierarchy
@ -127,41 +103,11 @@ public class ErrorPageErrorHandler extends ErrorHandler
//try servlet 3.x global error page
if (error_page == null)
{
error_page = _errorPages.get(GLOBAL_ERROR_PAGE);
return error_page;
}
if (error_page!=null)
{
String old_error_page=(String)request.getAttribute(ERROR_PAGE);
if (old_error_page==null || !old_error_page.equals(error_page))
{
request.setAttribute(ERROR_PAGE, error_page);
Dispatcher dispatcher = (Dispatcher) _servletContext.getRequestDispatcher(error_page);
try
{
if(dispatcher!=null)
{
dispatcher.error(request, response);
return;
}
else
{
LOG.warn("No error page "+error_page);
}
}
catch (ServletException e)
{
LOG.warn(Log.EXCEPTION, e);
return;
}
}
}
}
super.handle(target, baseRequest, request, response);
}
/* ------------------------------------------------------------ */
/**