jetty-9 improved exception logging

This commit is contained in:
Greg Wilkins 2012-09-24 13:10:36 +10:00
parent cb4e7982b1
commit 96dc4fe150
4 changed files with 27 additions and 17 deletions

View File

@ -938,7 +938,7 @@ public class HttpParser
Thread.sleep(100);
String chars = BufferUtil.toDetailString(buffer);
BufferUtil.clear(buffer);
throw new IllegalStateException(String.format("%s %d/%d data when CLOSED:%s",this,len,_headerBytes,chars));
throw new IllegalStateException(String.format("%s %d/%d>%d data when CLOSED:%s",this,len,_headerBytes,_maxHeaderBytes,chars));
}
BufferUtil.clear(buffer);
}

View File

@ -577,6 +577,14 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable
if (info.getStatus() < 200)
_committed.set(false);
}
catch (EofException e)
{
LOG.debug(e);
// TODO is it worthwhile sending if we are at EoF?
// "application" info failed to commit, commit with a failsafe 500 info
_transport.send(HttpGenerator.RESPONSE_500_INFO,null,true);
throw e;
}
catch (Exception e)
{
LOG.warn(e);

View File

@ -114,7 +114,7 @@ public class HttpOutput extends ServletOutputStream
_channel.write(BufferUtil.EMPTY_BUFFER, false);
}
public boolean checkAllWritten()
public boolean checkAllWritten() throws IOException
{
return _channel.getResponse().checkAllContentWritten(_written);
}

View File

@ -702,28 +702,30 @@ public class Response implements HttpServletResponse
_fields.putLongField(HttpHeader.CONTENT_LENGTH.toString(), len);
if (_contentLength > 0)
checkAllContentWritten(written);
}
public boolean checkAllContentWritten(long written)
{
if (_contentLength >= 0 && written >= _contentLength)
{
try
{
switch (_outputType)
{
case WRITER:
_writer.close();
break;
case STREAM:
getOutputStream().close();
}
checkAllContentWritten(written);
}
catch (IOException e)
catch(IOException e)
{
throw new RuntimeIOException(e);
}
}
}
public boolean checkAllContentWritten(long written) throws IOException
{
if (_contentLength >= 0 && written >= _contentLength)
{
switch (_outputType)
{
case WRITER:
_writer.close();
break;
case STREAM:
getOutputStream().close();
}
return true;
}
return false;