Merge branch 'master' into jetty-9.4.x-Feature

This commit is contained in:
Greg Wilkins 2016-03-02 17:32:36 +01:00
commit 0e6d886b01
3 changed files with 14 additions and 8 deletions

View File

@ -761,7 +761,7 @@ public class HttpOutput extends ServletOutputStream implements Runnable
} }
if (_channel.isCommitted()) if (_channel.isCommitted())
{ {
callback.failed(new IOException("committed")); callback.failed(new IOException("cannot sendContent(), output already committed"));
return; return;
} }

View File

@ -1091,7 +1091,7 @@ public class Response implements HttpServletResponse
public void setBufferSize(int size) public void setBufferSize(int size)
{ {
if (isCommitted() || getContentCount() > 0) if (isCommitted() || getContentCount() > 0)
throw new IllegalStateException("Committed or content written"); throw new IllegalStateException("cannot set buffer size on committed response");
if (size <= 0) if (size <= 0)
size = __MIN_BUFFER_SIZE; size = __MIN_BUFFER_SIZE;
_out.setBufferSize(size); _out.setBufferSize(size);
@ -1175,7 +1175,7 @@ public class Response implements HttpServletResponse
public void resetBuffer() public void resetBuffer()
{ {
if (isCommitted()) if (isCommitted())
throw new IllegalStateException("Committed"); throw new IllegalStateException("cannot reset buffer on committed response");
_out.resetBuffer(); _out.resetBuffer();
} }

View File

@ -34,6 +34,7 @@ import javax.servlet.AsyncContext;
import javax.servlet.AsyncEvent; import javax.servlet.AsyncEvent;
import javax.servlet.AsyncListener; import javax.servlet.AsyncListener;
import javax.servlet.DispatcherType; import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.ServletRequestWrapper; import javax.servlet.ServletRequestWrapper;
import javax.servlet.ServletResponseWrapper; import javax.servlet.ServletResponseWrapper;
@ -45,6 +46,8 @@ import javax.servlet.http.HttpServletResponseWrapper;
import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.DebugListener; import org.eclipse.jetty.server.DebugListener;
import org.eclipse.jetty.server.Dispatcher;
import org.eclipse.jetty.server.HttpChannel;
import org.eclipse.jetty.server.QuietServletException; import org.eclipse.jetty.server.QuietServletException;
import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.RequestLog; import org.eclipse.jetty.server.RequestLog;
@ -117,7 +120,6 @@ public class AsyncServletTest
context.setErrorHandler(_errorHandler); context.setErrorHandler(_errorHandler);
_errorHandler.addErrorPage(300,599,"/error/custom"); _errorHandler.addErrorPage(300,599,"/error/custom");
_servletHandler=context.getServletHandler(); _servletHandler=context.getServletHandler();
ServletHolder holder=new ServletHolder(_servlet); ServletHolder holder=new ServletHolder(_servlet);
holder.setAsyncSupported(true); holder.setAsyncSupported(true);
@ -199,7 +201,7 @@ public class AsyncServletTest
@Test @Test
public void testAsyncNotSupportedAsync() throws Exception public void testAsyncNotSupportedAsync() throws Exception
{ {
((StdErrLog)getLogger(ServletHandler.class)).setHideStacks(true); ((StdErrLog)getLogger(HttpChannel.class)).setHideStacks(true);
try try
{ {
_expectedCode="500 "; _expectedCode="500 ";
@ -207,16 +209,18 @@ public class AsyncServletTest
Assert.assertThat(response,Matchers.startsWith("HTTP/1.1 500 ")); Assert.assertThat(response,Matchers.startsWith("HTTP/1.1 500 "));
assertThat(__history,contains( assertThat(__history,contains(
"REQUEST /ctx/noasync/info", "REQUEST /ctx/noasync/info",
"initial" "initial",
"ERROR /ctx/error/custom",
"!initial"
)); ));
assertContains("HTTP ERROR: 500",response); assertContains("500",response);
assertContains("!asyncSupported",response); assertContains("!asyncSupported",response);
assertContains("AsyncServletTest$AsyncServlet",response); assertContains("AsyncServletTest$AsyncServlet",response);
} }
finally finally
{ {
((StdErrLog)getLogger(ServletHandler.class)).setHideStacks(false); ((StdErrLog)getLogger(HttpChannel.class)).setHideStacks(false);
} }
} }
@ -1003,6 +1007,8 @@ public class AsyncServletTest
else if(request.getDispatcherType()==DispatcherType.ERROR) else if(request.getDispatcherType()==DispatcherType.ERROR)
{ {
response.getOutputStream().println("ERROR DISPATCH: "+request.getContextPath()+request.getServletPath()+request.getPathInfo()); response.getOutputStream().println("ERROR DISPATCH: "+request.getContextPath()+request.getServletPath()+request.getPathInfo());
response.getOutputStream().println(""+request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE));
response.getOutputStream().println(""+request.getAttribute(RequestDispatcher.ERROR_MESSAGE));
} }
else else
{ {