Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2014-08-13 05:55:19 +0000
committerGreg Wilkins2014-08-13 05:56:02 +0000
commit2af613a28b1ea51e5aca5cb9ffe3989147749568 (patch)
tree2a836396c8e86a71b65411b9f2c40fc5c30d54a1
parent9a848e3425cb6357038beb3f6f4888fea5c12385 (diff)
downloadorg.eclipse.jetty.project-2af613a28b1ea51e5aca5cb9ffe3989147749568.tar.gz
org.eclipse.jetty.project-2af613a28b1ea51e5aca5cb9ffe3989147749568.tar.xz
org.eclipse.jetty.project-2af613a28b1ea51e5aca5cb9ffe3989147749568.zip
improved debugging output
-rw-r--r--jetty-http/src/main/java/org/eclipse/jetty/http/HttpContent.java6
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java7
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/ResourceCache.java2
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java13
-rw-r--r--jetty-servlets/src/main/java/org/eclipse/jetty/servlets/gzip/GzipHttpOutput.java37
5 files changed, 50 insertions, 15 deletions
diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpContent.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpContent.java
index ebae56d15c..1554f443ab 100644
--- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpContent.java
+++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpContent.java
@@ -168,5 +168,11 @@ public interface HttpContent
{
_resource.close();
}
+
+ @Override
+ public String toString()
+ {
+ return String.format("%s@%x{r=%s}",this.getClass().getSimpleName(),hashCode(),_resource);
+ }
}
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java
index 12a23d5fb3..d7cea8b4e5 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java
@@ -643,6 +643,9 @@ public class HttpOutput extends ServletOutputStream implements Runnable
if (buffer!=null)
{
+ if (LOG.isDebugEnabled())
+ LOG.debug("sendContent({}=={},{},direct={})",httpContent,BufferUtil.toDetailString(buffer),callback,_channel.useDirectBuffers());
+
sendContent(buffer,callback);
return;
}
@@ -650,6 +653,8 @@ public class HttpOutput extends ServletOutputStream implements Runnable
ReadableByteChannel rbc=httpContent.getReadableByteChannel();
if (rbc!=null)
{
+ if (LOG.isDebugEnabled())
+ LOG.debug("sendContent({}=={},{},direct={})",httpContent,rbc,callback,_channel.useDirectBuffers());
// Close of the rbc is done by the async sendContent
sendContent(rbc,callback);
return;
@@ -658,6 +663,8 @@ public class HttpOutput extends ServletOutputStream implements Runnable
InputStream in = httpContent.getInputStream();
if ( in!=null )
{
+ if (LOG.isDebugEnabled())
+ LOG.debug("sendContent({}=={},{},direct={})",httpContent,in,callback,_channel.useDirectBuffers());
sendContent(in,callback);
return;
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceCache.java b/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceCache.java
index dc686260cd..3e811fe82d 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceCache.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/ResourceCache.java
@@ -504,7 +504,7 @@ public class ResourceCache
@Override
public String toString()
{
- return String.format("%s %s %d %s %s",_resource,_resource.exists(),_resource.lastModified(),_contentType,_lastModifiedBytes);
+ return String.format("CachedContent@%x{r=%s,e=%b,lm=%d,ct=%s}",hashCode(),_resource,_resource.exists(),BufferUtil.toString(_lastModifiedBytes),_contentType);
}
}
}
diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
index cf22ca3b4c..705cefff14 100644
--- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
+++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
@@ -494,7 +494,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
}
if (LOG.isDebugEnabled())
- LOG.debug("uri="+request.getRequestURI()+" resource="+resource+(content!=null?" content":""));
+ LOG.debug(String.format("uri=%s, resource=%s, content=%s",request.getRequestURI(),resource,content));
// Handle resource
if (resource==null || !resource.exists())
@@ -863,7 +863,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
throws IOException
{
final long content_length = (content==null)?resource.length():content.getContentLength();
-
+
// Get the output stream (or writer)
OutputStream out =null;
boolean written;
@@ -881,6 +881,9 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
out = new WriterOutputStream(response.getWriter());
written=true; // there may be data in writer buffer, so assume written
}
+
+ if (LOG.isDebugEnabled())
+ LOG.debug(String.format("sendData content=%s out=%s async=%b",content,out,request.isAsyncSupported()));
if ( reqRanges == null || !reqRanges.hasMoreElements() || content_length<0)
{
@@ -935,6 +938,12 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
LOG.warn(x);
context.complete();
}
+
+ @Override
+ public String toString()
+ {
+ return String.format("DefaultServlet@%x$CB", DefaultServlet.this.hashCode());
+ }
});
}
// otherwise write content blocking
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/gzip/GzipHttpOutput.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/gzip/GzipHttpOutput.java
index 47136b9cbd..0156746081 100644
--- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/gzip/GzipHttpOutput.java
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/gzip/GzipHttpOutput.java
@@ -324,22 +324,22 @@ public class GzipHttpOutput extends HttpOutput
{
private final ByteBuffer _input;
private final ByteBuffer _content;
- private final boolean _complete;
+ private final boolean _last;
public GzipBufferCB(ByteBuffer content, boolean complete, Callback callback)
{
super(callback);
_input=getHttpChannel().getByteBufferPool().acquire(Math.min(_factory.getBufferSize(),content.remaining()),false);
_content=content;
- _complete=complete;
+ _last=complete;
}
@Override
protected Action process() throws Exception
{
if (_deflater.needsInput())
- {
+ {
if (BufferUtil.isEmpty(_content))
- {
+ {
if (_deflater.finished())
{
_factory.recycle(_deflater);
@@ -349,38 +349,51 @@ public class GzipHttpOutput extends HttpOutput
return Action.SUCCEEDED;
}
- if (!_complete)
+ if (!_last)
+ {
return Action.SUCCEEDED;
+ }
}
else
{
BufferUtil.clearToFill(_input);
- BufferUtil.put(_content,_input);
+ int took=BufferUtil.put(_content,_input);
BufferUtil.flipToFlush(_input,0);
-
+ if (took==0)
+ throw new IllegalStateException();
+
byte[] array=_input.array();
int off=_input.arrayOffset()+_input.position();
int len=_input.remaining();
_crc.update(array,off,len);
_deflater.setInput(array,off,len);
- if (_complete && BufferUtil.isEmpty(_content))
+ if (_last && BufferUtil.isEmpty(_content))
_deflater.finish();
}
}
BufferUtil.compact(_buffer);
int off=_buffer.arrayOffset()+_buffer.limit();
- int len=_buffer.capacity()-_buffer.limit() - (_complete?8:0);
+ int len=_buffer.capacity()-_buffer.limit() - (_last?8:0);
int produced=_deflater.deflate(_buffer.array(),off,len,Deflater.NO_FLUSH);
+ if (produced==0)
+ {
+ LOG.warn(String.format("AsyncGzipFilter NO PROGRESS!!!! content=%s, input=%s, last=%b, deflater=%s finished=%b",
+ BufferUtil.toDetailString(_content),
+ BufferUtil.toDetailString(_input),
+ _last,
+ _deflater,
+ _deflater.finished()));
+ }
_buffer.limit(_buffer.limit()+produced);
- boolean complete=_deflater.finished();
+ boolean finished=_deflater.finished();
- if (complete)
+ if (finished)
addTrailer();
- superWrite(_buffer,complete,this);
+ superWrite(_buffer,finished,this);
return Action.SCHEDULED;
}

Back to the top