hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1641928 - in /httpcomponents/httpcore/trunk: httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ httpcore-nio/src/main/java/org/apache/http/nio/entity/ httpcore-nio/src/main/java/org/apache/http/nio/reactor/ httpcore-nio/src/main/j...
Date Wed, 26 Nov 2014 20:29:19 GMT
Author: olegk
Date: Wed Nov 26 20:29:18 2014
New Revision: 1641928

URL: http://svn.apache.org/r1641928
Log:
Eliminated BufferInfo interface

Removed:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/BufferInfo.java
Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/SessionInputBuffer.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/SessionOutputBuffer.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ContentInputBuffer.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ContentOutputBuffer.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ExpandableBuffer.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/IdentityInputStream.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SessionInputBufferImpl.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/SessionInputBuffer.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/SessionOutputBuffer.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java?rev=1641928&r1=1641927&r2=1641928&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java
Wed Nov 26 20:29:18 2014
@@ -33,7 +33,6 @@ import java.nio.channels.WritableByteCha
 
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.impl.io.HttpTransportMetricsImpl;
-import org.apache.http.io.BufferInfo;
 import org.apache.http.nio.reactor.SessionOutputBuffer;
 import org.apache.http.util.CharArrayBuffer;
 
@@ -49,8 +48,6 @@ public class ChunkEncoder extends Abstra
     private final int fragHint;
     private final CharArrayBuffer lineBuffer;
 
-    private final BufferInfo bufferinfo;
-
     /**
      * @since 4.3
      *
@@ -69,11 +66,6 @@ public class ChunkEncoder extends Abstra
         super(channel, buffer, metrics);
         this.fragHint = fragementSizeHint > 0 ? fragementSizeHint : 0;
         this.lineBuffer = new CharArrayBuffer(16);
-        if (buffer instanceof BufferInfo) {
-            this.bufferinfo = (BufferInfo) buffer;
-        } else {
-            this.bufferinfo = null;
-        }
     }
 
     public ChunkEncoder(
@@ -94,11 +86,7 @@ public class ChunkEncoder extends Abstra
         while (src.hasRemaining()) {
             int chunk = src.remaining();
             int avail;
-            if (this.bufferinfo != null) {
-                avail = this.bufferinfo.available();
-            } else {
-                avail = 4096;
-            }
+            avail = this.buffer.available();
 
             // subtract the length of the longest chunk header
             // 12345678\r\n

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java?rev=1641928&r1=1641927&r2=1641928&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/ContentInputStream.java
Wed Nov 26 20:29:18 2014
@@ -31,7 +31,6 @@ import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.io.BufferInfo;
 import org.apache.http.nio.util.ContentInputBuffer;
 import org.apache.http.util.Args;
 
@@ -53,11 +52,7 @@ public class ContentInputStream extends 
 
     @Override
     public int available() throws IOException {
-        if (this.buffer instanceof BufferInfo) {
-            return ((BufferInfo) this.buffer).length();
-        } else {
-            return super.available();
-        }
+        return this.buffer.length();
     }
 
     @Override

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/SessionInputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/SessionInputBuffer.java?rev=1641928&r1=1641927&r2=1641928&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/SessionInputBuffer.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/SessionInputBuffer.java
Wed Nov 26 20:29:18 2014
@@ -62,6 +62,20 @@ public interface SessionInputBuffer {
     int length();
 
     /**
+     * Returns total capacity of the buffer
+     *
+     * @return total capacity
+     */
+    int capacity();
+
+    /**
+     * Returns available space in the buffer.
+     *
+     * @return available space.
+     */
+    int available();
+
+    /**
      * Makes an attempt to fill the buffer with data from the given
      * {@link ReadableByteChannel}.
      *

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/SessionOutputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/SessionOutputBuffer.java?rev=1641928&r1=1641927&r2=1641928&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/SessionOutputBuffer.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/reactor/SessionOutputBuffer.java
Wed Nov 26 20:29:18 2014
@@ -55,6 +55,20 @@ public interface SessionOutputBuffer {
     boolean hasData();
 
     /**
+     * Returns total capacity of the buffer
+     *
+     * @return total capacity
+     */
+    int capacity();
+
+    /**
+     * Returns available space in the buffer.
+     *
+     * @return available space.
+     */
+    int available();
+
+    /**
      * Returns the length of this buffer.
      *
      * @return buffer length.

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ContentInputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ContentInputBuffer.java?rev=1641928&r1=1641927&r2=1641928&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ContentInputBuffer.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ContentInputBuffer.java
Wed Nov 26 20:29:18 2014
@@ -37,6 +37,13 @@ import java.io.IOException;
 public interface ContentInputBuffer {
 
     /**
+     * Return length data stored in the buffer
+     *
+     * @return data length
+     */
+    int length();
+
+    /**
      * Resets the buffer by clearing its state and stored content.
      */
     void reset();

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ContentOutputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ContentOutputBuffer.java?rev=1641928&r1=1641927&r2=1641928&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ContentOutputBuffer.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/ContentOutputBuffer.java
Wed Nov 26 20:29:18 2014
@@ -37,6 +37,13 @@ import java.io.IOException;
 public interface ContentOutputBuffer {
 
     /**
+     * Return length data stored in the buffer
+     *
+     * @return data length
+     */
+    int length();
+
+    /**
      * Resets the buffer by clearing its state and stored content.
      */
     void reset();

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=1641928&r1=1641927&r2=1641928&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
Wed Nov 26 20:29:18 2014
@@ -30,7 +30,6 @@ package org.apache.http.nio.util;
 import java.nio.ByteBuffer;
 
 import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.io.BufferInfo;
 import org.apache.http.util.Args;
 
 /**
@@ -43,7 +42,7 @@ import org.apache.http.util.Args;
  * @since 4.0
  */
 @NotThreadSafe
-public class ExpandableBuffer implements BufferInfo {
+public class ExpandableBuffer {
 
     public final static int INPUT_MODE = 0;
     public final static int OUTPUT_MODE = 1;
@@ -136,7 +135,6 @@ public class ExpandableBuffer implements
      *
      * @return total capacity.
      */
-    @Override
     public int capacity() {
         return this.buffer.capacity();
     }
@@ -157,7 +155,6 @@ public class ExpandableBuffer implements
      *
      * @return buffer length.
      */
-    @Override
     public int length() {
         setOutputMode();
         return this.buffer.remaining();
@@ -168,7 +165,6 @@ public class ExpandableBuffer implements
      *
      * @return buffer length.
      */
-    @Override
     public int available() {
         setInputMode();
         return this.buffer.remaining();

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java?rev=1641928&r1=1641927&r2=1641928&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
Wed Nov 26 20:29:18 2014
@@ -37,7 +37,6 @@ import org.apache.http.MalformedChunkCod
 import org.apache.http.TruncatedChunkException;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.config.MessageConstraints;
-import org.apache.http.io.BufferInfo;
 import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.util.Args;
 import org.apache.http.util.CharArrayBuffer;
@@ -118,12 +117,8 @@ public class ChunkedInputStream extends 
 
     @Override
     public int available() throws IOException {
-        if (this.in instanceof BufferInfo) {
-            final int len = ((BufferInfo) this.in).length();
-            return Math.min(len, this.chunkSize - this.pos);
-        } else {
-            return 0;
-        }
+        final int len = this.in.length();
+        return Math.min(len, this.chunkSize - this.pos);
     }
 
     /**

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java?rev=1641928&r1=1641927&r2=1641928&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
Wed Nov 26 20:29:18 2014
@@ -32,7 +32,6 @@ import java.io.InputStream;
 
 import org.apache.http.ConnectionClosedException;
 import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.io.BufferInfo;
 import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.util.Args;
 
@@ -113,12 +112,8 @@ public class ContentLengthInputStream ex
 
     @Override
     public int available() throws IOException {
-        if (this.in instanceof BufferInfo) {
-            final int len = ((BufferInfo) this.in).length();
-            return Math.min(len, (int) (this.contentLength - this.pos));
-        } else {
-            return 0;
-        }
+        final int len = this.in.length();
+        return Math.min(len, (int) (this.contentLength - this.pos));
     }
 
     /**

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/IdentityInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/IdentityInputStream.java?rev=1641928&r1=1641927&r2=1641928&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/IdentityInputStream.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/IdentityInputStream.java
Wed Nov 26 20:29:18 2014
@@ -31,7 +31,6 @@ import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.io.BufferInfo;
 import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.util.Args;
 
@@ -66,11 +65,7 @@ public class IdentityInputStream extends
 
     @Override
     public int available() throws IOException {
-        if (this.in instanceof BufferInfo) {
-            return ((BufferInfo) this.in).length();
-        } else {
-            return 0;
-        }
+        return this.in.length();
     }
 
     @Override

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SessionInputBufferImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SessionInputBufferImpl.java?rev=1641928&r1=1641927&r2=1641928&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SessionInputBufferImpl.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SessionInputBufferImpl.java
Wed Nov 26 20:29:18 2014
@@ -38,7 +38,6 @@ import org.apache.http.Consts;
 import org.apache.http.MessageConstraintException;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.config.MessageConstraints;
-import org.apache.http.io.BufferInfo;
 import org.apache.http.io.HttpTransportMetrics;
 import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.util.Args;
@@ -58,7 +57,7 @@ import org.apache.http.util.CharArrayBuf
  * @since 4.3
  */
 @NotThreadSafe
-public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
+public class SessionInputBufferImpl implements SessionInputBuffer {
 
     private final HttpTransportMetricsImpl metrics;
     private final byte[] buffer;

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java?rev=1641928&r1=1641927&r2=1641928&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java
Wed Nov 26 20:29:18 2014
@@ -36,7 +36,6 @@ import java.nio.charset.CoderResult;
 
 import org.apache.http.Consts;
 import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.io.BufferInfo;
 import org.apache.http.io.HttpTransportMetrics;
 import org.apache.http.io.SessionOutputBuffer;
 import org.apache.http.util.Args;
@@ -55,7 +54,7 @@ import org.apache.http.util.CharArrayBuf
  * @since 4.3
  */
 @NotThreadSafe
-public class SessionOutputBufferImpl implements SessionOutputBuffer, BufferInfo {
+public class SessionOutputBufferImpl implements SessionOutputBuffer {
 
     private static final byte[] CRLF = new byte[] {Consts.CR, Consts.LF};
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/SessionInputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/SessionInputBuffer.java?rev=1641928&r1=1641927&r2=1641928&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/SessionInputBuffer.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/SessionInputBuffer.java
Wed Nov 26 20:29:18 2014
@@ -43,6 +43,27 @@ import org.apache.http.util.CharArrayBuf
 public interface SessionInputBuffer {
 
     /**
+     * Return length data stored in the buffer
+     *
+     * @return data length
+     */
+    int length();
+
+    /**
+     * Returns total capacity of the buffer
+     *
+     * @return total capacity
+     */
+    int capacity();
+
+    /**
+     * Returns available space in the buffer.
+     *
+     * @return available space.
+     */
+    int available();
+
+    /**
      * Reads up to {@code len} bytes of data from the session buffer into
      * an array of bytes.  An attempt is made to read as many as
      * {@code len} bytes, but a smaller number may be read, possibly

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/SessionOutputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/SessionOutputBuffer.java?rev=1641928&r1=1641927&r2=1641928&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/SessionOutputBuffer.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/io/SessionOutputBuffer.java
Wed Nov 26 20:29:18 2014
@@ -43,6 +43,27 @@ import org.apache.http.util.CharArrayBuf
 public interface SessionOutputBuffer {
 
     /**
+     * Return length data stored in the buffer
+     *
+     * @return data length
+     */
+    int length();
+
+    /**
+     * Returns total capacity of the buffer
+     *
+     * @return total capacity
+     */
+    int capacity();
+
+    /**
+     * Returns available space in the buffer.
+     *
+     * @return available space.
+     */
+    int available();
+
+    /**
      * Writes {@code len} bytes from the specified byte array
      * starting at offset {@code off} to this session buffer.
      * <p>



Mime
View raw message