You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2014/02/18 10:18:57 UTC

svn commit: r1569240 - in /httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods: AsyncByteConsumer.java AsyncCharConsumer.java

Author: olegk
Date: Tue Feb 18 09:18:57 2014
New Revision: 1569240

URL: http://svn.apache.org/r1569240
Log:
Made internal buffers final in AsyncCharConsumer and AsyncByteConsumer

Modified:
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java?rev=1569240&r1=1569239&r2=1569240&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncByteConsumer.java Tue Feb 18 09:18:57 2014
@@ -48,12 +48,11 @@ import org.apache.http.util.Asserts;
  */
 public abstract class AsyncByteConsumer<T> extends AbstractAsyncResponseConsumer<T> {
 
-    private final int bufSize;
-    private ByteBuffer bbuf;
+    private final ByteBuffer bbuf;
 
     public AsyncByteConsumer(final int bufSize) {
         super();
-        this.bufSize = bufSize;
+        this.bbuf = ByteBuffer.allocate(bufSize);
     }
 
     public AsyncByteConsumer() {
@@ -74,8 +73,7 @@ public abstract class AsyncByteConsumer<
 
     @Override
     protected final void onEntityEnclosed(
-            final HttpEntity entity, final ContentType contentType) {
-        this.bbuf = ByteBuffer.allocate(this.bufSize);
+            final HttpEntity entity, final ContentType contentType) throws IOException {
     }
 
     @Override
@@ -112,7 +110,6 @@ public abstract class AsyncByteConsumer<
 
     @Override
     protected void releaseResources() {
-        this.bbuf = null;
     }
 
 }

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java?rev=1569240&r1=1569239&r2=1569240&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java (original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/nio/client/methods/AsyncCharConsumer.java Tue Feb 18 09:18:57 2014
@@ -53,15 +53,16 @@ import org.apache.http.util.Asserts;
  */
 public abstract class AsyncCharConsumer<T> extends AbstractAsyncResponseConsumer<T> {
 
-    private final int bufSize;
-    private ContentType contentType;
+    private final ByteBuffer bbuf;
+    private final CharBuffer cbuf;
+
     private CharsetDecoder chardecoder;
-    private ByteBuffer bbuf;
-    private CharBuffer cbuf;
+    private ContentType contentType;
 
     public AsyncCharConsumer(final int bufSize) {
         super();
-        this.bufSize = bufSize;
+        this.bbuf = ByteBuffer.allocate(bufSize);
+        this.cbuf = CharBuffer.allocate(bufSize);
     }
 
     public AsyncCharConsumer() {
@@ -89,8 +90,6 @@ public abstract class AsyncCharConsumer<
             charset = HTTP.DEF_CONTENT_CHARSET;
         }
         this.chardecoder = charset.newDecoder();
-        this.bbuf = ByteBuffer.allocate(this.bufSize);
-        this.cbuf = CharBuffer.allocate(this.bufSize);
     }
 
     @Override
@@ -143,9 +142,6 @@ public abstract class AsyncCharConsumer<
 
     @Override
     protected void releaseResources() {
-        this.chardecoder = null;
-        this.bbuf = null;
-        this.cbuf = null;
     }
 
 }