437996 avoid async status race by not setting 200 on handled
This commit is contained in:
parent
31ce7cabda
commit
28ad689bcb
|
@ -612,7 +612,6 @@ package org.eclipse.jetty.http;
|
|||
*/
|
||||
public class HttpStatus
|
||||
{
|
||||
public final static int NOT_SET_000 = 0;
|
||||
public final static int CONTINUE_100 = 100;
|
||||
public final static int SWITCHING_PROTOCOLS_101 = 101;
|
||||
public final static int PROCESSING_102 = 102;
|
||||
|
|
|
@ -45,7 +45,7 @@ public class ValidUrlRuleTest extends AbstractRuleTestCase
|
|||
|
||||
_rule.matchAndApply(_request.getRequestURI(), _request, _response);
|
||||
|
||||
assertEquals(0,_response.getStatus());
|
||||
assertEquals(200,_response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1865,9 +1865,6 @@ public class Request implements HttpServletRequest
|
|||
public void setHandled(boolean h)
|
||||
{
|
||||
_handled = h;
|
||||
Response r=getResponse();
|
||||
if (_handled && r.getStatus()==0)
|
||||
r.setStatus(200);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -112,7 +112,7 @@ public class Response implements HttpServletResponse
|
|||
private final HttpFields _fields = new HttpFields();
|
||||
private final AtomicInteger _include = new AtomicInteger();
|
||||
private HttpOutput _out;
|
||||
private int _status = HttpStatus.NOT_SET_000;
|
||||
private int _status = HttpStatus.OK_200;
|
||||
private String _reason;
|
||||
private Locale _locale;
|
||||
private MimeTypes.Type _mimeType;
|
||||
|
@ -137,7 +137,7 @@ public class Response implements HttpServletResponse
|
|||
|
||||
protected void recycle()
|
||||
{
|
||||
_status = HttpStatus.NOT_SET_000;
|
||||
_status = HttpStatus.OK_200;
|
||||
_reason = null;
|
||||
_locale = null;
|
||||
_mimeType = null;
|
||||
|
@ -1290,8 +1290,6 @@ public class Response implements HttpServletResponse
|
|||
|
||||
protected ResponseInfo newResponseInfo()
|
||||
{
|
||||
if (_status == HttpStatus.NOT_SET_000)
|
||||
_status = HttpStatus.OK_200;
|
||||
return new ResponseInfo(_channel.getRequest().getHttpVersion(), _fields, getLongContentLength(), getStatus(), getReason(), _channel.getRequest().isHead());
|
||||
}
|
||||
|
||||
|
|
|
@ -193,35 +193,35 @@ public class StatisticsHandler extends HandlerWrapper implements Graceful
|
|||
}
|
||||
}
|
||||
|
||||
private void updateResponse(Request request)
|
||||
protected void updateResponse(Request request)
|
||||
{
|
||||
Response response = request.getResponse();
|
||||
switch (response.getStatus() / 100)
|
||||
if (request.isHandled())
|
||||
{
|
||||
case 0:
|
||||
if (request.isHandled())
|
||||
switch (response.getStatus() / 100)
|
||||
{
|
||||
case 1:
|
||||
_responses1xx.incrementAndGet();
|
||||
break;
|
||||
case 2:
|
||||
_responses2xx.incrementAndGet();
|
||||
else
|
||||
break;
|
||||
case 3:
|
||||
_responses3xx.incrementAndGet();
|
||||
break;
|
||||
case 4:
|
||||
_responses4xx.incrementAndGet();
|
||||
break;
|
||||
case 1:
|
||||
_responses1xx.incrementAndGet();
|
||||
break;
|
||||
case 2:
|
||||
_responses2xx.incrementAndGet();
|
||||
break;
|
||||
case 3:
|
||||
_responses3xx.incrementAndGet();
|
||||
break;
|
||||
case 4:
|
||||
_responses4xx.incrementAndGet();
|
||||
break;
|
||||
case 5:
|
||||
_responses5xx.incrementAndGet();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
case 5:
|
||||
_responses5xx.incrementAndGet();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
// will fall through to not found handler
|
||||
_responses4xx.incrementAndGet();
|
||||
_responsesTotalBytes.addAndGet(response.getContentCount());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue