Rewritten toString() methods using String.format().
This commit is contained in:
parent
0b85184722
commit
59c111bde1
|
@ -149,7 +149,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Connection handle() throws IOException;
|
public abstract Connection handle() throws IOException;
|
||||||
|
|
||||||
|
|
||||||
public boolean isIdle()
|
public boolean isIdle()
|
||||||
{
|
{
|
||||||
|
@ -275,7 +275,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen
|
||||||
_endp.close();
|
_endp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(status)
|
switch(status)
|
||||||
{
|
{
|
||||||
case HttpStatus.CONTINUE_100:
|
case HttpStatus.CONTINUE_100:
|
||||||
|
@ -295,7 +295,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen
|
||||||
_status=status;
|
_status=status;
|
||||||
exchange.getEventListener().onResponseStatus(version,status,reason);
|
exchange.getEventListener().onResponseStatus(version,status,reason);
|
||||||
exchange.setStatus(HttpExchange.STATUS_PARSING_HEADERS);
|
exchange.setStatus(HttpExchange.STATUS_PARSING_HEADERS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -353,16 +353,19 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "HttpConnection@" + hashCode() + "//" +
|
return String.format("%s@%x//%s,g=%s,p=%s",
|
||||||
(_destination==null?"?.?.?.?:??":(_destination.getAddress().getHost() + ":" + _destination.getAddress().getPort()))+
|
getClass().getSimpleName(),
|
||||||
",g="+_generator.getState()+",p="+_parser.getState();
|
hashCode(),
|
||||||
|
_destination == null ? "?.?.?.?:??" : _destination.getAddress(),
|
||||||
|
_generator,
|
||||||
|
_parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toDetailString()
|
public String toDetailString()
|
||||||
|
|
|
@ -11,14 +11,14 @@ public abstract class AbstractConnection implements Connection
|
||||||
private static final Logger LOG = Log.getLogger(AbstractConnection.class);
|
private static final Logger LOG = Log.getLogger(AbstractConnection.class);
|
||||||
|
|
||||||
private final long _timeStamp;
|
private final long _timeStamp;
|
||||||
protected final EndPoint _endp;
|
protected final EndPoint _endp;
|
||||||
|
|
||||||
public AbstractConnection(EndPoint endp)
|
public AbstractConnection(EndPoint endp)
|
||||||
{
|
{
|
||||||
_endp=(EndPoint)endp;
|
_endp=(EndPoint)endp;
|
||||||
_timeStamp = System.currentTimeMillis();
|
_timeStamp = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractConnection(EndPoint endp,long timestamp)
|
public AbstractConnection(EndPoint endp,long timestamp)
|
||||||
{
|
{
|
||||||
_endp=(EndPoint)endp;
|
_endp=(EndPoint)endp;
|
||||||
|
@ -29,7 +29,7 @@ public abstract class AbstractConnection implements Connection
|
||||||
{
|
{
|
||||||
return _timeStamp;
|
return _timeStamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EndPoint getEndPoint()
|
public EndPoint getEndPoint()
|
||||||
{
|
{
|
||||||
return _endp;
|
return _endp;
|
||||||
|
@ -52,13 +52,19 @@ public abstract class AbstractConnection implements Connection
|
||||||
catch(IOException e2)
|
catch(IOException e2)
|
||||||
{
|
{
|
||||||
LOG.ignore(e2);
|
LOG.ignore(e2);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ import org.eclipse.jetty.util.URIUtil;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.util.resource.Resource;
|
import org.eclipse.jetty.util.resource.Resource;
|
||||||
import org.eclipse.jetty.util.thread.Timeout;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>A HttpConnection represents the connection of a HTTP client to the server
|
* <p>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()
|
public String toString()
|
||||||
{
|
{
|
||||||
return super.toString()+" "+_parser+" "+_generator+" "+_requests;
|
return String.format("%s,g=%s,p=%s,r=%d",
|
||||||
|
super.toString(),
|
||||||
|
_generator,
|
||||||
|
_parser,
|
||||||
|
_requests);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
Loading…
Reference in New Issue