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 2016/11/26 09:43:04 UTC

svn commit: r1771452 - in /httpcomponents/httpcore/trunk/httpcore5/src: main/java/org/apache/hc/core5/http/io/ test/java/org/apache/hc/core5/http/io/

Author: olegk
Date: Sat Nov 26 09:43:03 2016
New Revision: 1771452

URL: http://svn.apache.org/viewvc?rev=1771452&view=rev
Log:
Copied EofSensorInputStream from HttpClient

Added:
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorInputStream.java   (contents, props changed)
      - copied, changed from r1771445, httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorInputStream.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorWatcher.java   (contents, props changed)
      - copied, changed from r1771446, httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorWatcher.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/io/TestEofSensorInputStream.java   (contents, props changed)
      - copied, changed from r1771446, httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/io/TestEofSensorInputStream.java

Copied: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorInputStream.java (from r1771445, httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorInputStream.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorInputStream.java?p2=httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorInputStream.java&p1=httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorInputStream.java&r1=1771445&r2=1771452&rev=1771452&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorInputStream.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorInputStream.java Sat Nov 26 09:43:03 2016
@@ -24,12 +24,11 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.hc.client5.http.io;
+package org.apache.hc.core5.http.io;
 
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.apache.hc.core5.annotation.NotThreadSafe;
 import org.apache.hc.core5.util.Args;
 
 /**
@@ -43,15 +42,14 @@ import org.apache.hc.core5.util.Args;
  */
 // don't use FilterInputStream as the base class, we'd have to
 // override markSupported(), mark(), and reset() to disable them
-@NotThreadSafe
-public class EofSensorInputStream extends InputStream implements ConnectionReleaseTrigger {
+public class EofSensorInputStream extends InputStream {
 
     /**
      * The wrapped input stream, while accessible.
      * The value changes to {@code null} when the wrapped stream
      * becomes inaccessible.
      */
-    protected InputStream wrappedStream;
+    private InputStream wrappedStream;
 
     /**
      * Indicates whether this stream itself is closed.
@@ -104,7 +102,7 @@ public class EofSensorInputStream extend
      *
      * @throws IOException      if this stream is already closed
      */
-    protected boolean isReadAllowed() throws IOException {
+    private boolean isReadAllowed() throws IOException {
         if (selfClosed) {
             throw new IOException("Attempted read on closed stream.");
         }
@@ -191,7 +189,7 @@ public class EofSensorInputStream extend
      * @throws IOException
      *          in case of an IO problem on closing the underlying stream
      */
-    protected void checkEOF(final int eof) throws IOException {
+    private void checkEOF(final int eof) throws IOException {
 
         final InputStream toCheckStream = wrappedStream;
         if ((toCheckStream != null) && (eof < 0)) {
@@ -220,7 +218,7 @@ public class EofSensorInputStream extend
      * @throws IOException
      *          in case of an IO problem on closing the underlying stream
      */
-    protected void checkClose() throws IOException {
+    private void checkClose() throws IOException {
 
         final InputStream toCloseStream = wrappedStream;
         if (toCloseStream != null) {
@@ -240,8 +238,7 @@ public class EofSensorInputStream extend
 
     /**
      * Detects stream abort and notifies the watcher.
-     * There's not much to detect since this is called by
-     * {@link #abortConnection abortConnection}.
+     * There's not much to detect since this is called by {@link #abort()}.
      * The watcher will only be notified if this stream is aborted
      * for the first time and before EOF has been detected or the
      * stream has been {@link #close closed} gracefully.
@@ -251,7 +248,7 @@ public class EofSensorInputStream extend
      * @throws IOException
      *          in case of an IO problem on closing the underlying stream
      */
-    protected void checkAbort() throws IOException {
+    private void checkAbort() throws IOException {
 
         final InputStream toAbortStream = wrappedStream;
         if (toAbortStream != null) {
@@ -270,22 +267,13 @@ public class EofSensorInputStream extend
     }
 
     /**
-     * Same as {@link #close close()}.
-     */
-    @Override
-    public void releaseConnection() throws IOException {
-        close();
-    }
-
-    /**
      * Aborts this stream.
      * This is a special version of {@link #close close()} which prevents
      * re-use of the underlying connection, if any. Calling this method
      * indicates that there should be no attempt to read until the end of
      * the stream.
      */
-    @Override
-    public void abortConnection() throws IOException {
+    public void abort() throws IOException {
         // tolerate multiple calls
         selfClosed = true;
         checkAbort();

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorInputStream.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorInputStream.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Sat Nov 26 09:43:03 2016
@@ -0,0 +1,6 @@
+/httpcomponents/httpclient/branches/4.0.x/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorInputStream.java:950681-950688
+/httpcomponents/httpclient/branches/4.1.x/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorInputStream.java:1079518-1080165
+/httpcomponents/httpclient/branches/4.2.x/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorInputStream.java:1376150-1376151,1447062
+/httpcomponents/httpclient/branches/branch_4_1/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorInputStream.java:755593-811107
+/httpcomponents/httpclient/branches/conn-mgmt-redesign/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorInputStream.java:1154913-1160573
+/httpcomponents/httpclient/branches/notice-plugin-test/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorInputStream.java:1024348-1031454

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorInputStream.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorWatcher.java (from r1771446, httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorWatcher.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorWatcher.java?p2=httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorWatcher.java&p1=httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorWatcher.java&r1=1771446&r2=1771452&rev=1771452&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorWatcher.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorWatcher.java Sat Nov 26 09:43:03 2016
@@ -24,7 +24,7 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.hc.client5.http.io;
+package org.apache.hc.core5.http.io;
 
 import java.io.IOException;
 import java.io.InputStream;

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorWatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorWatcher.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorWatcher.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Sat Nov 26 09:43:03 2016
@@ -0,0 +1,6 @@
+/httpcomponents/httpclient/branches/4.0.x/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorWatcher.java:950681-950688
+/httpcomponents/httpclient/branches/4.1.x/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorWatcher.java:1079518-1080165
+/httpcomponents/httpclient/branches/4.2.x/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorWatcher.java:1376150-1376151,1447062
+/httpcomponents/httpclient/branches/branch_4_1/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorWatcher.java:755593-811107
+/httpcomponents/httpclient/branches/conn-mgmt-redesign/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorWatcher.java:1154913-1160573
+/httpcomponents/httpclient/branches/notice-plugin-test/httpclient5/src/main/java/org/apache/hc/client5/http/io/EofSensorWatcher.java:1024348-1031454

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/EofSensorWatcher.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/io/TestEofSensorInputStream.java (from r1771446, httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/io/TestEofSensorInputStream.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/io/TestEofSensorInputStream.java?p2=httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/io/TestEofSensorInputStream.java&p1=httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/io/TestEofSensorInputStream.java&r1=1771446&r2=1771452&rev=1771452&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/io/TestEofSensorInputStream.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/io/TestEofSensorInputStream.java Sat Nov 26 09:43:03 2016
@@ -24,7 +24,7 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.hc.client5.http.io;
+package org.apache.hc.core5.http.io;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -82,7 +82,7 @@ public class TestEofSensorInputStream {
     public void testReleaseConnection() throws Exception {
         Mockito.when(eofwatcher.streamClosed(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
 
-        eofstream.releaseConnection();
+        eofstream.close();
 
         Assert.assertTrue(eofstream.isSelfClosed());
         Assert.assertNull(eofstream.getWrappedStream());
@@ -90,14 +90,14 @@ public class TestEofSensorInputStream {
         Mockito.verify(instream, Mockito.times(1)).close();
         Mockito.verify(eofwatcher).streamClosed(instream);
 
-        eofstream.releaseConnection();
+        eofstream.close();
     }
 
     @Test
     public void testAbortConnection() throws Exception {
         Mockito.when(eofwatcher.streamAbort(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
 
-        eofstream.abortConnection();
+        eofstream.abort();
 
         Assert.assertTrue(eofstream.isSelfClosed());
         Assert.assertNull(eofstream.getWrappedStream());
@@ -105,7 +105,7 @@ public class TestEofSensorInputStream {
         Mockito.verify(instream, Mockito.times(1)).close();
         Mockito.verify(eofwatcher).streamAbort(instream);
 
-        eofstream.abortConnection();
+        eofstream.abort();
     }
 
     @Test
@@ -113,7 +113,7 @@ public class TestEofSensorInputStream {
         Mockito.when(eofwatcher.streamAbort(Mockito.<InputStream>any())).thenThrow(new IOException());
 
         try {
-            eofstream.abortConnection();
+            eofstream.abort();
             Assert.fail("IOException expected");
         } catch (final IOException ex) {
         }
@@ -210,7 +210,7 @@ public class TestEofSensorInputStream {
     public void testReadAfterAbort() throws Exception {
         Mockito.when(eofwatcher.streamAbort(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
 
-        eofstream.abortConnection();
+        eofstream.abort();
 
         try {
             eofstream.read();

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/io/TestEofSensorInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/io/TestEofSensorInputStream.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/io/TestEofSensorInputStream.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Sat Nov 26 09:43:03 2016
@@ -0,0 +1,6 @@
+/httpcomponents/httpclient/branches/4.0.x/httpclient5/src/test/java/org/apache/hc/client5/http/io/TestEofSensorInputStream.java:950681-950688
+/httpcomponents/httpclient/branches/4.1.x/httpclient5/src/test/java/org/apache/hc/client5/http/io/TestEofSensorInputStream.java:1079518-1080165
+/httpcomponents/httpclient/branches/4.2.x/httpclient5/src/test/java/org/apache/hc/client5/http/io/TestEofSensorInputStream.java:1376150-1376151,1447062
+/httpcomponents/httpclient/branches/branch_4_1/httpclient5/src/test/java/org/apache/hc/client5/http/io/TestEofSensorInputStream.java:755593-811107
+/httpcomponents/httpclient/branches/conn-mgmt-redesign/httpclient5/src/test/java/org/apache/hc/client5/http/io/TestEofSensorInputStream.java:1154913-1160573
+/httpcomponents/httpclient/branches/notice-plugin-test/httpclient5/src/test/java/org/apache/hc/client5/http/io/TestEofSensorInputStream.java:1024348-1031454

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/io/TestEofSensorInputStream.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain