From 85f50da0533d99510dccaa7644e8c16f6951996e Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 5 Oct 2016 09:15:33 +0200 Subject: [PATCH] Code cleanups. --- .../eclipse/jetty/http/GZIPContentDecoder.java | 18 +++++++++--------- .../org/eclipse/jetty/server/HttpInput.java | 7 +------ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/GZIPContentDecoder.java b/jetty-http/src/main/java/org/eclipse/jetty/http/GZIPContentDecoder.java index 49f5aa5b746..57cfa0fa51b 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/GZIPContentDecoder.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/GZIPContentDecoder.java @@ -28,9 +28,9 @@ import org.eclipse.jetty.util.BufferUtil; /** * Decoder for the "gzip" encoding. - *

An Decode that inflates gzip compressed data that has been + *

+ * A decoder that inflates gzip compressed data that has been * optimized for async usage with minimal data copies. - * */ public class GZIPContentDecoder { @@ -91,7 +91,9 @@ public class GZIPContentDecoder protected boolean decodedChunk(ByteBuffer chunk) { if (_inflated==null) + { _inflated=chunk; + } else { int size = _inflated.remaining() + chunk.remaining(); @@ -103,7 +105,7 @@ public class GZIPContentDecoder } else { - ByteBuffer bigger=_pool==null?BufferUtil.allocate(size):_pool.acquire(size,false); + ByteBuffer bigger=acquire(size); int pos=BufferUtil.flipToFill(bigger); BufferUtil.put(_inflated,bigger); BufferUtil.put(chunk,bigger); @@ -113,11 +115,9 @@ public class GZIPContentDecoder _inflated = bigger; } } - return false; } - - + /** * Inflate compressed data. *

Inflation continues until the compressed block end is reached, there is no @@ -170,7 +170,7 @@ public class GZIPContentDecoder while (true) { if (buffer==null) - buffer = acquire(); + buffer = acquire(_bufferSize); try { @@ -396,9 +396,9 @@ public class GZIPContentDecoder /** * @return An indirect buffer of the configured buffersize either from the pool or freshly allocated. */ - public ByteBuffer acquire() + public ByteBuffer acquire(int capacity) { - return _pool==null?BufferUtil.allocate(_bufferSize):_pool.acquire(_bufferSize,false); + return _pool==null?BufferUtil.allocate(capacity):_pool.acquire(capacity,false); } /** diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java index 1b5e42d626e..839493b50a1 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java @@ -25,7 +25,6 @@ import java.util.ArrayDeque; import java.util.Deque; import java.util.Objects; import java.util.concurrent.Executor; -import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -48,10 +47,6 @@ import org.eclipse.jetty.util.log.Logger; * whether there is content to consume and the EOF state that tells whether an EOF has arrived. Only once the content has been consumed the content state is * moved to the EOF state. */ -/** - * @author gregw - * - */ public class HttpInput extends ServletInputStream implements Runnable { /** @@ -109,7 +104,7 @@ public class HttpInput extends ServletInputStream implements Runnable @Override public Content readFrom(Content content) { - return _next.readFrom(_prev.readFrom(content)); + return getNext().readFrom(getPrev().readFrom(content)); } }