hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1658165 - in /httpcomponents/httpcore/trunk: httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ httpcore-nio/src/main/java/org/apache/http/nio/util/ httpcore-nio/src/tes...
Date Sun, 08 Feb 2015 13:15:16 GMT
Author: olegk
Date: Sun Feb  8 13:15:15 2015
New Revision: 1658165

URL: http://svn.apache.org/r1658165
Log:
Do not use protected variables

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentEncoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ExpandableBuffer.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedInputBuffer.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleInputBuffer.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleOutputBuffer.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/WritableByteChannelMock.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestTruncatedChunks.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/util/ContentEncoderMock.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/IncomingHttpEntity.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
Sun Feb  8 13:15:15 2015
@@ -46,11 +46,11 @@ import org.apache.http.util.Args;
 @NotThreadSafe
 public abstract class AbstractContentDecoder implements ContentDecoder {
 
-    protected final ReadableByteChannel channel;
-    protected final SessionInputBuffer buffer;
-    protected final HttpTransportMetricsImpl metrics;
+    final ReadableByteChannel channel;
+    final SessionInputBuffer buffer;
+    final HttpTransportMetricsImpl metrics;
 
-    protected boolean completed;
+    boolean completed;
 
     /**
      * Creates an instance of this class.
@@ -73,6 +73,18 @@ public abstract class AbstractContentDec
         this.metrics = metrics;
     }
 
+    protected ReadableByteChannel channel() {
+        return this.channel;
+    }
+
+    protected SessionInputBuffer buffer() {
+        return this.buffer;
+    }
+
+    protected HttpTransportMetricsImpl metrics() {
+        return this.metrics;
+    }
+
     @Override
     public boolean isCompleted() {
         return this.completed;

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentEncoder.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentEncoder.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentEncoder.java
Sun Feb  8 13:15:15 2015
@@ -47,14 +47,11 @@ import org.apache.http.util.Asserts;
 @NotThreadSafe
 public abstract class AbstractContentEncoder implements ContentEncoder {
 
-    protected final WritableByteChannel channel;
-    protected final SessionOutputBuffer buffer;
-    protected final HttpTransportMetricsImpl metrics;
+    final WritableByteChannel channel;
+    final SessionOutputBuffer buffer;
+    final HttpTransportMetricsImpl metrics;
 
-    /**
-     * TODO: make private
-     */
-    protected boolean completed;
+    boolean completed;
 
     /**
      * Creates an instance of this class.
@@ -77,6 +74,18 @@ public abstract class AbstractContentEnc
         this.metrics = metrics;
     }
 
+    protected WritableByteChannel channel() {
+        return this.channel;
+    }
+
+    protected SessionOutputBuffer buffer() {
+        return this.buffer;
+    }
+
+    protected HttpTransportMetricsImpl metrics() {
+        return this.metrics;
+    }
+
     @Override
     public boolean isCompleted() {
         return this.completed;

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageParser.java
Sun Feb  8 13:15:15 2015
@@ -52,7 +52,7 @@ import org.apache.http.util.CharArrayBuf
  * @since 4.0
  */
 @NotThreadSafe
-public abstract class AbstractMessageParser<T extends HttpMessage> implements NHttpMessageParser<T>
{
+public abstract class AbstractMessageParser<T extends HttpMessage<?>> implements
NHttpMessageParser<T> {
 
     private static final int READ_HEAD_LINE = 0;
     private static final int READ_HEADERS   = 1;

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractMessageWriter.java
Sun Feb  8 13:15:15 2015
@@ -49,7 +49,7 @@ import org.apache.http.util.CharArrayBuf
  * @since 4.0
  */
 @NotThreadSafe
-public abstract class AbstractMessageWriter<T extends HttpMessage> implements NHttpMessageWriter<T>
{
+public abstract class AbstractMessageWriter<T extends HttpMessage<?>> implements
NHttpMessageWriter<T> {
 
     private final CharArrayBuffer lineBuf;
     private final LineFormatter lineFormatter;

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
Sun Feb  8 13:15:15 2015
@@ -51,8 +51,7 @@ import org.apache.http.util.Args;
  * @since 4.0
  */
 @NotThreadSafe
-public class IdentityDecoder extends AbstractContentDecoder
-        implements FileContentDecoder {
+public class IdentityDecoder extends AbstractContentDecoder implements FileContentDecoder
{
 
     public IdentityDecoder(
             final ReadableByteChannel channel,

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityEncoder.java
Sun Feb  8 13:15:15 2015
@@ -50,8 +50,7 @@ import org.apache.http.nio.reactor.Sessi
  * @since 4.0
  */
 @NotThreadSafe
-public class IdentityEncoder extends AbstractContentEncoder
-        implements FileContentEncoder {
+public class IdentityEncoder extends AbstractContentEncoder implements FileContentEncoder
{
 
     private final int fragHint;
 

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
Sun Feb  8 13:15:15 2015
@@ -53,8 +53,7 @@ import org.apache.http.util.Args;
  * @since 4.0
  */
 @NotThreadSafe
-public class LengthDelimitedDecoder extends AbstractContentDecoder
-        implements FileContentDecoder {
+public class LengthDelimitedDecoder extends AbstractContentDecoder implements FileContentDecoder
{
 
     private final long contentLength;
 

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.java
Sun Feb  8 13:15:15 2015
@@ -52,8 +52,7 @@ import org.apache.http.util.Args;
  * @since 4.0
  */
 @NotThreadSafe
-public class LengthDelimitedEncoder extends AbstractContentEncoder
-        implements FileContentEncoder {
+public class LengthDelimitedEncoder extends AbstractContentEncoder implements FileContentEncoder
{
 
     private final long contentLength;
     private final int fragHint;

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
Sun Feb  8 13:15:15 2015
@@ -154,16 +154,16 @@ public class SessionInputBufferImpl exte
     public int fill(final ReadableByteChannel channel) throws IOException {
         Args.notNull(channel, "Channel");
         setInputMode();
-        if (!this.buffer.hasRemaining()) {
+        if (!buffer().hasRemaining()) {
             expand();
         }
-        return channel.read(this.buffer);
+        return channel.read(buffer());
     }
 
     @Override
     public int read() {
         setOutputMode();
-        return this.buffer.get() & 0xff;
+        return buffer().get() & 0xff;
     }
 
     @Override
@@ -173,16 +173,16 @@ public class SessionInputBufferImpl exte
         }
         setOutputMode();
         final int len = Math.min(dst.remaining(), maxLen);
-        final int chunk = Math.min(this.buffer.remaining(), len);
-        if (this.buffer.remaining() > chunk) {
-            final int oldLimit = this.buffer.limit();
-            final int newLimit = this.buffer.position() + chunk;
-            this.buffer.limit(newLimit);
-            dst.put(this.buffer);
-            this.buffer.limit(oldLimit);
+        final int chunk = Math.min(buffer().remaining(), len);
+        if (buffer().remaining() > chunk) {
+            final int oldLimit = buffer().limit();
+            final int newLimit = buffer().position() + chunk;
+            buffer().limit(newLimit);
+            dst.put(buffer());
+            buffer().limit(oldLimit);
             return len;
         } else {
-            dst.put(this.buffer);
+            dst.put(buffer());
         }
         return chunk;
     }
@@ -202,14 +202,14 @@ public class SessionInputBufferImpl exte
         }
         setOutputMode();
         final int bytesRead;
-        if (this.buffer.remaining() > maxLen) {
-            final int oldLimit = this.buffer.limit();
-            final int newLimit = oldLimit - (this.buffer.remaining() - maxLen);
-            this.buffer.limit(newLimit);
-            bytesRead = dst.write(this.buffer);
-            this.buffer.limit(oldLimit);
+        if (buffer().remaining() > maxLen) {
+            final int oldLimit = buffer().limit();
+            final int newLimit = oldLimit - (buffer().remaining() - maxLen);
+            buffer().limit(newLimit);
+            bytesRead = dst.write(buffer());
+            buffer().limit(oldLimit);
         } else {
-            bytesRead = dst.write(this.buffer);
+            bytesRead = dst.write(buffer());
         }
         return bytesRead;
     }
@@ -220,7 +220,7 @@ public class SessionInputBufferImpl exte
             return 0;
         }
         setOutputMode();
-        return dst.write(this.buffer);
+        return dst.write(buffer());
     }
 
     @Override
@@ -231,8 +231,8 @@ public class SessionInputBufferImpl exte
         setOutputMode();
         // See if there is LF char present in the buffer
         int pos = -1;
-        for (int i = this.buffer.position(); i < this.buffer.limit(); i++) {
-            final int b = this.buffer.get(i);
+        for (int i = buffer().position(); i < buffer().limit(); i++) {
+            final int b = buffer().get(i);
             if (b == Consts.LF) {
                 pos = i + 1;
                 break;
@@ -241,39 +241,39 @@ public class SessionInputBufferImpl exte
 
         final int maxLineLen = this.constraints.getMaxLineLength();
         if (maxLineLen > 0) {
-            final int currentLen = (pos > 0 ? pos : this.buffer.limit()) - this.buffer.position();
+            final int currentLen = (pos > 0 ? pos : buffer().limit()) - buffer().position();
             if (currentLen >= maxLineLen) {
                 throw new MessageConstraintException("Maximum line length limit exceeded");
             }
         }
 
         if (pos == -1) {
-            if (endOfStream && this.buffer.hasRemaining()) {
+            if (endOfStream && buffer().hasRemaining()) {
                 // No more data. Get the rest
-                pos = this.buffer.limit();
+                pos = buffer().limit();
             } else {
                 // Either no complete line present in the buffer
                 // or no more data is expected
                 return false;
             }
         }
-        final int origLimit = this.buffer.limit();
-        this.buffer.limit(pos);
+        final int origLimit = buffer().limit();
+        buffer().limit(pos);
 
-        final int requiredCapacity = this.buffer.limit() - this.buffer.position();
+        final int requiredCapacity = buffer().limit() - buffer().position();
         // Ensure capacity of len assuming ASCII as the most likely charset
         linebuffer.ensureCapacity(requiredCapacity);
 
         if (this.chardecoder == null) {
-            if (this.buffer.hasArray()) {
-                final byte[] b = this.buffer.array();
-                final int off = this.buffer.position();
-                final int len = this.buffer.remaining();
+            if (buffer().hasArray()) {
+                final byte[] b = buffer().array();
+                final int off = buffer().position();
+                final int len = buffer().remaining();
                 linebuffer.append(b, off, len);
-                this.buffer.position(off + len);
+                buffer().position(off + len);
             } else {
-                while (this.buffer.hasRemaining()) {
-                    linebuffer.append((char) (this.buffer.get() & 0xff));
+                while (buffer().hasRemaining()) {
+                    linebuffer.append((char) (buffer().get() & 0xff));
                 }
             }
         } else {
@@ -284,7 +284,7 @@ public class SessionInputBufferImpl exte
 
             for (;;) {
                 final CoderResult result = this.chardecoder.decode(
-                        this.buffer,
+                        buffer(),
                         this.charbuffer,
                         true);
                 if (result.isError()) {
@@ -315,7 +315,7 @@ public class SessionInputBufferImpl exte
             }
 
         }
-        this.buffer.limit(origLimit);
+        buffer().limit(origLimit);
 
         // discard LF if found
         int l = linebuffer.length();

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java
Sun Feb  8 13:15:15 2015
@@ -116,7 +116,7 @@ public class SessionOutputBufferImpl ext
     public int flush(final WritableByteChannel channel) throws IOException {
         Args.notNull(channel, "Channel");
         setOutputMode();
-        return channel.write(this.buffer);
+        return channel.write(buffer());
     }
 
     @Override
@@ -125,9 +125,9 @@ public class SessionOutputBufferImpl ext
             return;
         }
         setInputMode();
-        final int requiredCapacity = this.buffer.position() + src.remaining();
+        final int requiredCapacity = buffer().position() + src.remaining();
         ensureCapacity(requiredCapacity);
-        this.buffer.put(src);
+        buffer().put(src);
     }
 
     @Override
@@ -136,7 +136,7 @@ public class SessionOutputBufferImpl ext
             return;
         }
         setInputMode();
-        src.read(this.buffer);
+        src.read(buffer());
     }
 
     private void write(final byte[] b) {
@@ -146,9 +146,9 @@ public class SessionOutputBufferImpl ext
         setInputMode();
         final int off = 0;
         final int len = b.length;
-        final int requiredCapacity = this.buffer.position() + len;
+        final int requiredCapacity = buffer().position() + len;
         ensureCapacity(requiredCapacity);
-        this.buffer.put(b, off, len);
+        buffer().put(b, off, len);
     }
 
     private void writeCRLF() {
@@ -164,19 +164,19 @@ public class SessionOutputBufferImpl ext
         // Do not bother if the buffer is empty
         if (linebuffer.length() > 0 ) {
             if (this.charencoder == null) {
-                final int requiredCapacity = this.buffer.position() + linebuffer.length();
+                final int requiredCapacity = buffer().position() + linebuffer.length();
                 ensureCapacity(requiredCapacity);
-                if (this.buffer.hasArray()) {
-                    final byte[] b = this.buffer.array();
+                if (buffer().hasArray()) {
+                    final byte[] b = buffer().array();
                     final int len = linebuffer.length();
-                    final int off = this.buffer.position();
+                    final int off = buffer().position();
                     for (int i = 0; i < len; i++) {
                         b[off + i]  = (byte) linebuffer.charAt(i);
                     }
-                    this.buffer.position(off + len);
+                    buffer().position(off + len);
                 } else {
                     for (int i = 0; i < linebuffer.length(); i++) {
-                        this.buffer.put((byte) linebuffer.charAt(i));
+                        buffer().put((byte) linebuffer.charAt(i));
                     }
                 }
             } else {
@@ -200,7 +200,7 @@ public class SessionOutputBufferImpl ext
 
                     boolean retry = true;
                     while (retry) {
-                        final CoderResult result = this.charencoder.encode(this.charbuffer,
this.buffer, eol);
+                        final CoderResult result = this.charencoder.encode(this.charbuffer,
buffer(), eol);
                         if (result.isError()) {
                             result.throwException();
                         }
@@ -216,7 +216,7 @@ public class SessionOutputBufferImpl ext
                 // flush the encoder
                 boolean retry = true;
                 while (retry) {
-                    final CoderResult result = this.charencoder.flush(this.buffer);
+                    final CoderResult result = this.charencoder.flush(buffer());
                     if (result.isError()) {
                         result.throwException();
                     }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ExpandableBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ExpandableBuffer.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ExpandableBuffer.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ExpandableBuffer.java
Sun Feb  8 13:15:15 2015
@@ -50,7 +50,7 @@ public class ExpandableBuffer {
     private final ByteBufferAllocator allocator;
 
     private int mode;
-    protected ByteBuffer buffer = null;
+    private ByteBuffer buffer;
 
     /**
      * Allocates buffer of the given size using the given allocator.
@@ -75,10 +75,14 @@ public class ExpandableBuffer {
      *
      * @return current input/output mode.
      */
-    protected int getMode() {
+    protected int mode() {
         return this.mode;
     }
 
+    protected ByteBuffer buffer() {
+        return this.buffer;
+    }
+
     /**
      * Sets output mode. The buffer can now be read from.
      */
@@ -182,7 +186,7 @@ public class ExpandableBuffer {
     public String toString() {
         final StringBuilder sb = new StringBuilder();
         sb.append("[mode=");
-        if (getMode() == INPUT_MODE) {
+        if (mode() == INPUT_MODE) {
             sb.append("in");
         } else {
             sb.append("out");

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedInputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedInputBuffer.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedInputBuffer.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedInputBuffer.java
Sun Feb  8 13:15:15 2015
@@ -107,13 +107,13 @@ public class SharedInputBuffer extends E
             setInputMode();
             int totalRead = 0;
             int bytesRead;
-            while ((bytesRead = decoder.read(this.buffer)) > 0) {
+            while ((bytesRead = decoder.read(buffer())) > 0) {
                 totalRead += bytesRead;
             }
             if (bytesRead == -1 || decoder.isCompleted()) {
                 this.endOfStream = true;
             }
-            if (!this.buffer.hasRemaining()) {
+            if (!buffer().hasRemaining()) {
                 if (this.ioctrl != null) {
                     this.ioctrl.suspendInput();
                 }
@@ -242,7 +242,7 @@ public class SharedInputBuffer extends E
             if (isEndOfStream()) {
                 return -1;
             }
-            return this.buffer.get() & 0xff;
+            return buffer().get() & 0xff;
         } finally {
             this.lock.unlock();
         }
@@ -266,10 +266,10 @@ public class SharedInputBuffer extends E
             }
             setOutputMode();
             int chunk = len;
-            if (chunk > this.buffer.remaining()) {
-                chunk = this.buffer.remaining();
+            if (chunk > buffer().remaining()) {
+                chunk = buffer().remaining();
             }
-            this.buffer.get(b, off, chunk);
+            buffer().get(b, off, chunk);
             return chunk;
         } finally {
             this.lock.unlock();

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java
Sun Feb  8 13:15:15 2015
@@ -148,7 +148,7 @@ public class SharedOutputBuffer extends
             setOutputMode();
             int bytesWritten = 0;
             if (super.hasData()) {
-                bytesWritten = encoder.write(this.buffer);
+                bytesWritten = encoder.write(buffer());
                 if (encoder.isCompleted()) {
                     this.endOfStream = true;
                 }
@@ -202,12 +202,12 @@ public class SharedOutputBuffer extends
             setInputMode();
             int remaining = len;
             while (remaining > 0) {
-                if (!this.buffer.hasRemaining()) {
+                if (!buffer().hasRemaining()) {
                     flushContent();
                     setInputMode();
                 }
-                final int chunk = Math.min(remaining, this.buffer.remaining());
-                this.buffer.put(b, pos, chunk);
+                final int chunk = Math.min(remaining, buffer().remaining());
+                buffer().put(b, pos, chunk);
                 remaining -= chunk;
                 pos += chunk;
             }
@@ -229,11 +229,11 @@ public class SharedOutputBuffer extends
         try {
             Asserts.check(!this.shutdown && !this.endOfStream, "Buffer already closed
for writing");
             setInputMode();
-            if (!this.buffer.hasRemaining()) {
+            if (!buffer().hasRemaining()) {
                 flushContent();
                 setInputMode();
             }
-            this.buffer.put((byte)b);
+            buffer().put((byte)b);
         } finally {
             this.lock.unlock();
         }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleInputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleInputBuffer.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleInputBuffer.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleInputBuffer.java
Sun Feb  8 13:15:15 2015
@@ -64,9 +64,9 @@ public class SimpleInputBuffer extends E
         setInputMode();
         int totalRead = 0;
         int bytesRead;
-        while ((bytesRead = decoder.read(this.buffer)) != -1) {
+        while ((bytesRead = decoder.read(buffer())) != -1) {
             if (bytesRead == 0) {
-                if (!this.buffer.hasRemaining()) {
+                if (!buffer().hasRemaining()) {
                     expand();
                 } else {
                     break;
@@ -91,7 +91,7 @@ public class SimpleInputBuffer extends E
             return -1;
         }
         setOutputMode();
-        return this.buffer.get() & 0xff;
+        return buffer().get() & 0xff;
     }
 
     @Override
@@ -104,10 +104,10 @@ public class SimpleInputBuffer extends E
         }
         setOutputMode();
         int chunk = len;
-        if (chunk > this.buffer.remaining()) {
-            chunk = this.buffer.remaining();
+        if (chunk > buffer().remaining()) {
+            chunk = buffer().remaining();
         }
-        this.buffer.get(b, off, chunk);
+        buffer().get(b, off, chunk);
         return chunk;
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleOutputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleOutputBuffer.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleOutputBuffer.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleOutputBuffer.java
Sun Feb  8 13:15:15 2015
@@ -57,7 +57,7 @@ public class SimpleOutputBuffer extends
 
     public int produceContent(final ContentEncoder encoder) throws IOException {
         setOutputMode();
-        final int bytesWritten = encoder.write(this.buffer);
+        final int bytesWritten = encoder.write(buffer());
         if (!hasData() && this.endOfStream) {
             encoder.complete();
         }
@@ -73,8 +73,8 @@ public class SimpleOutputBuffer extends
             return;
         }
         setInputMode();
-        ensureCapacity(this.buffer.position() + len);
-        this.buffer.put(b, off, len);
+        ensureCapacity(buffer().position() + len);
+        buffer().put(b, off, len);
     }
 
     public void write(final byte[] b) throws IOException {
@@ -94,7 +94,7 @@ public class SimpleOutputBuffer extends
         }
         setInputMode();
         ensureCapacity(this.capacity() + 1);
-        this.buffer.put((byte)b);
+        buffer().put((byte)b);
     }
 
     @Override

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/WritableByteChannelMock.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/WritableByteChannelMock.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/WritableByteChannelMock.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/WritableByteChannelMock.java
Sun Feb  8 13:15:15 2015
@@ -56,11 +56,11 @@ public class WritableByteChannelMock imp
             setInputMode();
             if (this.capacityLimit > 0) {
                 if (this.curCapacity > 0) {
-                    final int requiredCapacity = this.buffer.position() + this.curCapacity;
+                    final int requiredCapacity = buffer().position() + this.curCapacity;
                     ensureCapacity(requiredCapacity);
                     int count = 0;
                     while (src.hasRemaining() && this.curCapacity > 0) {
-                        this.buffer.put(src.get());
+                        buffer().put(src.get());
                         count++;
                         this.curCapacity--;
                     }
@@ -70,9 +70,9 @@ public class WritableByteChannelMock imp
                 }
             } else {
                 final int chunk = src.remaining();
-                final int requiredCapacity = this.buffer.position() + src.remaining();
+                final int requiredCapacity = buffer().position() + src.remaining();
                 ensureCapacity(requiredCapacity);
-                this.buffer.put(src);
+                buffer().put(src);
                 return chunk;
             }
         }
@@ -93,11 +93,11 @@ public class WritableByteChannelMock imp
 
         public String dump(final Charset charset) {
             setOutputMode();
-            if (this.buffer.hasArray()) {
-                return toString(this.buffer.array(), this.buffer.position(), this.buffer.limit(),
+            if (buffer().hasArray()) {
+                return toString(buffer().array(), buffer().position(), buffer().limit(),
                     charset);
             } else {
-                final ByteBuffer dup = this.buffer.duplicate();
+                final ByteBuffer dup = buffer().duplicate();
                 final byte[] b = new byte[dup.remaining()];
                 int i = 0;
                 while (dup.hasRemaining()) {

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestTruncatedChunks.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestTruncatedChunks.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestTruncatedChunks.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestTruncatedChunks.java
Sun Feb  8 13:15:15 2015
@@ -121,19 +121,19 @@ public class TestTruncatedChunks extends
             if (!this.done) {
                 this.lineBuffer.clear();
                 this.lineBuffer.append(Integer.toHexString(GARBAGE.length * 10));
-                this.buffer.writeLine(this.lineBuffer);
-                this.buffer.write(ByteBuffer.wrap(GARBAGE));
+                this.buffer().writeLine(this.lineBuffer);
+                this.buffer().write(ByteBuffer.wrap(GARBAGE));
                 this.done = true;
                 chunk = GARBAGE.length;
             } else {
                 chunk = 0;
             }
-            final long bytesWritten = this.buffer.flush(this.channel);
+            final long bytesWritten = this.buffer().flush(this.channel());
             if (bytesWritten > 0) {
-                this.metrics.incrementBytesTransferred(bytesWritten);
+                this.metrics().incrementBytesTransferred(bytesWritten);
             }
-            if (!this.buffer.hasData()) {
-                this.channel.close();
+            if (!this.buffer().hasData()) {
+                this.channel().close();
             }
             return chunk;
         }

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/util/ContentEncoderMock.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/util/ContentEncoderMock.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/util/ContentEncoderMock.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/util/ContentEncoderMock.java
Sun Feb  8 13:15:15 2015
@@ -51,7 +51,7 @@ public class ContentEncoderMock extends
             return 0;
         }
         Asserts.check(!isCompleted(), "Decoding process already completed");
-        return this.channel.write(src);
+        return this.channel().write(src);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/IncomingHttpEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/IncomingHttpEntity.java?rev=1658165&r1=1658164&r2=1658165&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/IncomingHttpEntity.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/IncomingHttpEntity.java
Sun Feb  8 13:15:15 2015
@@ -36,6 +36,11 @@ import org.apache.http.entity.AbstractIm
 import org.apache.http.entity.HttpContentProducer;
 import org.apache.http.impl.io.EmptyInputStream;
 
+/**
+ * Represents entity received from an open connection.
+ *
+ * @since 5.0
+ */
 @NotThreadSafe
 public class IncomingHttpEntity extends AbstractImmutableHttpEntity implements HttpContentProducer
{
 



Mime
View raw message