Improved toString().

This commit is contained in:
Simone Bordet 2015-09-28 19:23:50 +02:00
parent 77fdfb8754
commit fd5c5b5779
5 changed files with 142 additions and 110 deletions

View File

@ -258,7 +258,11 @@ public abstract class AbstractConnection implements Connection
@Override @Override
public String toString() public String toString()
{ {
return String.format("%s@%x{%s}", getClass().getSimpleName(), hashCode(), _state.get()); return String.format("%s@%x[%s,%s]",
getClass().getSimpleName(),
hashCode(),
_state.get(),
_endPoint);
} }
public boolean next(State state, State next) public boolean next(State state, State next)

View File

@ -26,6 +26,7 @@ import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.DispatcherType; import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher; import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -512,8 +513,7 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable, H
_requests, _requests,
_committed.get(), _committed.get(),
_state.getState(), _state.getState(),
_state.getState()==HttpChannelState.State.IDLE?"-":_request.getRequestURI() _uri);
);
} }
@Override @Override

View File

@ -480,6 +480,24 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
_sendCallback.iterate(); _sendCallback.iterate();
} }
@Override
public void abort()
{
// 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 String toString()
{
return String.format("%s[p=%s,g=%s,c=%s]",
super.toString(),
_parser,
_generator,
_channel);
}
protected class HttpChannelOverHttp extends HttpChannel<ByteBuffer> protected class HttpChannelOverHttp extends HttpChannel<ByteBuffer>
{ {
public HttpChannelOverHttp(Connector connector, HttpConfiguration config, EndPoint endPoint, HttpTransport transport, HttpInput<ByteBuffer> input) public HttpChannelOverHttp(Connector connector, HttpConfiguration config, EndPoint endPoint, HttpTransport transport, HttpInput<ByteBuffer> input)
@ -748,14 +766,4 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
return String.format("%s[i=%s,cb=%s]",super.toString(),_info,_callback); return String.format("%s[i=%s,cb=%s]",super.toString(),_info,_callback);
} }
} }
@Override
public void abort()
{
// 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();
}
} }

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.server;
import java.io.IOException; import java.io.IOException;
import java.util.Objects; import java.util.Objects;
import javax.servlet.ReadListener; import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream; import javax.servlet.ServletInputStream;
@ -451,6 +452,18 @@ public abstract class HttpInput<T> extends ServletInputStream implements Runnabl
} }
} }
@Override
public String toString()
{
return String.format("%s@%x[r=%d,s=%s,e=%s,f=%s]",
getClass().getSimpleName(),
hashCode(),
_contentRead,
_contentState,
_eofState,
_onError);
}
protected static abstract class State protected static abstract class State
{ {
public void waitForContent(HttpInput<?> in) throws IOException public void waitForContent(HttpInput<?> in) throws IOException

View File

@ -40,6 +40,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import javax.servlet.AsyncContext; import javax.servlet.AsyncContext;
import javax.servlet.AsyncListener; import javax.servlet.AsyncListener;
import javax.servlet.DispatcherType; import javax.servlet.DispatcherType;
@ -2084,7 +2085,13 @@ public class Request implements HttpServletRequest
@Override @Override
public String toString() public String toString()
{ {
return (_handled?"[":"(") + getMethod() + " " + _uri + (_handled?"]@":")@") + hashCode() + " " + super.toString(); return String.format("%s%s%s %s%s@%x",
getClass().getSimpleName(),
_handled ? "[" : "(",
getMethod(),
_uri,
_handled ? "]" : ")",
hashCode());
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */