Improved toString().

Changes imported manually from branch 9.2.x.
This commit is contained in:
Simone Bordet 2015-09-29 12:06:01 +02:00
parent 1f2f62cff4
commit 90743d301a
5 changed files with 134 additions and 114 deletions

View File

@ -234,7 +234,10 @@ public abstract class AbstractConnection implements Connection
@Override
public String toString()
{
return String.format("%s@%x", getClass().getSimpleName(), hashCode());
return String.format("%s@%x[%s]",
getClass().getSimpleName(),
hashCode(),
_endPoint);
}
private class ReadCallback implements Callback
@ -256,5 +259,5 @@ public abstract class AbstractConnection implements Connection
{
return String.format("AC.ReadCB@%x{%s}", AbstractConnection.this.hashCode(),AbstractConnection.this);
}
};
}
}

View File

@ -554,8 +554,7 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
_requests,
_committed.get(),
_state.getState(),
_state.getState()==HttpChannelState.State.IDLE?"-":_request.getRequestURI()
);
_request.getHttpURI());
}
public void onRequest(MetaData.Request request)

View File

@ -517,6 +517,52 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
return new Content(c);
}
@Override
public void abort(Throwable failure)
{
// Do a direct close of the output, as this may indicate to a client that the
// response is bad either with RST or by abnormal completion of chunked response.
getEndPoint().close();
}
@Override
public boolean isPushSupported()
{
return false;
}
@Override
public void push(org.eclipse.jetty.http.MetaData.Request request)
{
LOG.debug("ignore push in {}",this);
}
public void asyncReadFillInterested()
{
getEndPoint().fillInterested(_asyncReadCallback);
}
public void blockingReadFillInterested()
{
getEndPoint().fillInterested(_blockingReadCallback);
}
public void blockingReadException(Throwable e)
{
_blockingReadCallback.failed(e);
}
@Override
public String toString()
{
return String.format("%s[p=%s,g=%s,c=%s][b=%s]",
super.toString(),
_parser,
_generator,
_channel,
BufferUtil.toDetailString(_requestBuffer));
}
private class Content extends HttpInput.Content
{
public Content(ByteBuffer content)
@ -764,48 +810,4 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
return String.format("%s[i=%s,cb=%s]",super.toString(),_info,_callback);
}
}
@Override
public void abort(Throwable failure)
{
// Do a direct close of the output, as this may indicate to a client that the
// response is bad either with RST or by abnormal completion of chunked response.
getEndPoint().close();
}
@Override
public boolean isPushSupported()
{
return false;
}
/**
* @see org.eclipse.jetty.server.HttpTransport#push(org.eclipse.jetty.http.MetaData.Request)
*/
@Override
public void push(org.eclipse.jetty.http.MetaData.Request request)
{
LOG.debug("ignore push in {}",this);
}
public void asyncReadFillInterested()
{
getEndPoint().fillInterested(_asyncReadCallback);
}
public void blockingReadFillInterested()
{
getEndPoint().fillInterested(_blockingReadCallback);
}
public void blockingReadException(Throwable e)
{
_blockingReadCallback.failed(e);
}
@Override
public String toString()
{
return super.toString()+"<--"+BufferUtil.toDetailString(_requestBuffer);
}
}

View File

@ -634,6 +634,16 @@ public class HttpInput extends ServletInputStream implements Runnable
}
}
@Override
public String toString()
{
return String.format("%s@%x[c=%d,s=%s]",
getClass().getSimpleName(),
hashCode(),
_contentConsumed,
_state);
}
public static class PoisonPillContent extends Content
{
private final String _name;

View File

@ -2171,7 +2171,7 @@ public class Request implements HttpServletRequest
*/
public void setAuthority(String host,int port)
{
_metadata.getURI().setAuthority(host,port);;
_metadata.getURI().setAuthority(host,port);
}
/* ------------------------------------------------------------ */
@ -2250,7 +2250,13 @@ public class Request implements HttpServletRequest
@Override
public String toString()
{
return (_handled?"[":"(") + getMethod() + " " + _metadata.getURI() + (_handled?"]@":")@") + hashCode() + " " + super.toString();
return String.format("%s%s%s %s%s@%x",
getClass().getSimpleName(),
_handled ? "[" : "(",
getMethod(),
getHttpURI(),
_handled ? "]" : ")",
hashCode());
}
/* ------------------------------------------------------------ */
@ -2321,7 +2327,7 @@ public class Request implements HttpServletRequest
IO.copy(is, os);
String content=new String(os.toByteArray(),charset==null?StandardCharsets.UTF_8:Charset.forName(charset));
if (_contentParameters == null)
_contentParameters = params == null ? new MultiMap<String>() : params;
_contentParameters = params == null ? new MultiMap<>() : params;
_contentParameters.add(mp.getName(), content);
}
os.reset();