From 43f14997d8103ceb23f887e76d35e650d9329ef0 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Mon, 9 Feb 2015 08:53:53 +0100 Subject: [PATCH] Improved toString() methods for better reporting during dump(). --- .../java/org/eclipse/jetty/client/HttpReceiver.java | 9 +++++++++ .../main/java/org/eclipse/jetty/client/HttpSender.java | 10 ++++++++++ .../eclipse/jetty/client/http/HttpChannelOverHTTP.java | 6 +++++- .../jetty/client/http/HttpConnectionOverHTTP.java | 5 +++-- .../jetty/client/http/HttpReceiverOverHTTP.java | 2 +- .../eclipse/jetty/client/http/HttpSenderOverHTTP.java | 6 ++++++ 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java index a11137d822c..b8c40b26913 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java @@ -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. */ diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpSender.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpSender.java index 16401a491dc..0f4533614e9 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpSender.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpSender.java @@ -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. */ diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java index 2e3b3dcd3c5..cf26c77308d 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java @@ -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); } } diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java index 10b80ce12bc..eb19049e7ca 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpConnectionOverHTTP.java @@ -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 diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java index cf3b898aa05..d1fd4c3ff8e 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java @@ -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); } } diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpSenderOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpSenderOverHTTP.java index 47654450a7b..6b85ba460c2 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpSenderOverHTTP.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpSenderOverHTTP.java @@ -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;