From 59c111bde19738cd5b5ca0629c6b800c001c6a35 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 24 Nov 2011 15:20:06 +0100 Subject: [PATCH] Rewritten toString() methods using String.format(). --- .../jetty/client/AbstractHttpConnection.java | 19 +++++++++++-------- .../eclipse/jetty/io/AbstractConnection.java | 18 ++++++++++++------ .../jetty/server/AbstractHttpConnection.java | 7 +++++-- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java index 868dbd4ba58..043334a2ba5 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java @@ -149,7 +149,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen } public abstract Connection handle() throws IOException; - + public boolean isIdle() { @@ -275,7 +275,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen _endp.close(); return; } - + switch(status) { case HttpStatus.CONTINUE_100: @@ -295,7 +295,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen _status=status; exchange.getEventListener().onResponseStatus(version,status,reason); exchange.setStatus(HttpExchange.STATUS_PARSING_HEADERS); - + } @Override @@ -353,16 +353,19 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen } } } - - + + } @Override public String toString() { - return "HttpConnection@" + hashCode() + "//" + - (_destination==null?"?.?.?.?:??":(_destination.getAddress().getHost() + ":" + _destination.getAddress().getPort()))+ - ",g="+_generator.getState()+",p="+_parser.getState(); + return String.format("%s@%x//%s,g=%s,p=%s", + getClass().getSimpleName(), + hashCode(), + _destination == null ? "?.?.?.?:??" : _destination.getAddress(), + _generator, + _parser); } public String toDetailString() diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java index 088102b9b65..f95cf5fedab 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java @@ -11,14 +11,14 @@ public abstract class AbstractConnection implements Connection private static final Logger LOG = Log.getLogger(AbstractConnection.class); private final long _timeStamp; - protected final EndPoint _endp; + protected final EndPoint _endp; public AbstractConnection(EndPoint endp) { _endp=(EndPoint)endp; _timeStamp = System.currentTimeMillis(); } - + public AbstractConnection(EndPoint endp,long timestamp) { _endp=(EndPoint)endp; @@ -29,7 +29,7 @@ public abstract class AbstractConnection implements Connection { return _timeStamp; } - + public EndPoint getEndPoint() { return _endp; @@ -52,13 +52,19 @@ public abstract class AbstractConnection implements Connection catch(IOException e2) { LOG.ignore(e2); - + } } } - + public String toString() { - return this.getClass().getSimpleName()+"@"+_endp.getLocalAddr()+":"+_endp.getLocalPort()+"<->"+_endp.getRemoteAddr()+":"+_endp.getRemotePort(); + return String.format("%s@%x//%s:%d<->%s:%d", + getClass().getSimpleName(), + hashCode(), + _endp.getLocalAddr(), + _endp.getLocalPort(), + _endp.getRemoteAddr(), + _endp.getRemotePort()); } } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java index 88473b64fe2..5251897be3f 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java @@ -55,7 +55,6 @@ import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.resource.Resource; -import org.eclipse.jetty.util.thread.Timeout; /** *

A HttpConnection represents the connection of a HTTP client to the server @@ -680,7 +679,11 @@ public abstract class AbstractHttpConnection extends AbstractConnection /* ------------------------------------------------------------ */ public String toString() { - return super.toString()+" "+_parser+" "+_generator+" "+_requests; + return String.format("%s,g=%s,p=%s,r=%d", + super.toString(), + _generator, + _parser, + _requests); } /* ------------------------------------------------------------ */