Improved toString() methods for better reporting during dump().

This commit is contained in:
Simone Bordet 2015-02-09 08:53:53 +01:00
parent 32ae2a15b2
commit 43f14997d8
6 changed files with 34 additions and 4 deletions

View File

@ -527,6 +527,15 @@ public abstract class HttpReceiver
return updated;
}
@Override
public String toString()
{
return String.format("%s@%x(rcv=%s)",
getClass().getSimpleName(),
hashCode(),
responseState);
}
/**
* The request states {@link HttpReceiver} goes through when receiving a response.
*/

View File

@ -547,6 +547,16 @@ public abstract class HttpSender implements AsyncContentProvider.Listener
return new IllegalStateException("Expected " + current + " found " + senderState.get() + " instead");
}
@Override
public String toString()
{
return String.format("%s@%x(req=%s,snd=%s)",
getClass().getSimpleName(),
hashCode(),
requestState,
senderState);
}
/**
* The request states {@link HttpSender} goes through when sending a request.
*/

View File

@ -105,6 +105,10 @@ public class HttpChannelOverHTTP extends HttpChannel
@Override
public String toString()
{
return String.format("%s@%x", getClass().getSimpleName(), hashCode());
return String.format("%s@%x(send=%s,recv=%s)",
getClass().getSimpleName(),
hashCode(),
sender,
receiver);
}
}

View File

@ -152,11 +152,12 @@ public class HttpConnectionOverHTTP extends AbstractConnection implements Connec
@Override
public String toString()
{
return String.format("%s@%h(l:%s <-> r:%s)",
return String.format("%s@%h(l:%s <-> r:%s)[%s]",
getClass().getSimpleName(),
this,
getEndPoint().getLocalAddress(),
getEndPoint().getRemoteAddress());
getEndPoint().getRemoteAddress(),
channel);
}
private class Delegate extends HttpConnection

View File

@ -302,6 +302,6 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
@Override
public String toString()
{
return String.format("%s@%x on %s", getClass().getSimpleName(), hashCode(), getHttpConnection());
return String.format("%s[%s]", super.toString(), parser);
}
}

View File

@ -208,6 +208,12 @@ public class HttpSenderOverHTTP extends HttpSender
getHttpChannel().getHttpConnection().getEndPoint().shutdownOutput();
}
@Override
public String toString()
{
return String.format("%s[%s]", super.toString(), generator);
}
private class ByteBufferRecyclerCallback implements Callback
{
private final Callback callback;