You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2018/08/03 17:05:01 UTC

httpcomponents-core git commit: Refactor duplicate messages into a new 0-arg constructor for org.apache.hc.core5.http.StreamClosedException.

Repository: httpcomponents-core
Updated Branches:
  refs/heads/master be2cf1e9b -> 635aad7b3


Refactor duplicate messages into a new 0-arg constructor for
org.apache.hc.core5.http.StreamClosedException.

Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/635aad7b
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/635aad7b
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/635aad7b

Branch: refs/heads/master
Commit: 635aad7b39f0875adee5e5155616736396f2615d
Parents: be2cf1e
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 3 11:04:57 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Aug 3 11:04:57 2018 -0600

----------------------------------------------------------------------
 RELEASE_NOTES.txt                                               | 3 +++
 .../java/org/apache/hc/core5/http/StreamClosedException.java    | 4 ++++
 .../org/apache/hc/core5/http/impl/io/ChunkedInputStream.java    | 4 ++--
 .../org/apache/hc/core5/http/impl/io/ChunkedOutputStream.java   | 4 ++--
 .../apache/hc/core5/http/impl/io/ContentLengthInputStream.java  | 4 ++--
 .../apache/hc/core5/http/impl/io/ContentLengthOutputStream.java | 4 ++--
 .../org/apache/hc/core5/http/impl/io/IdentityInputStream.java   | 4 ++--
 .../org/apache/hc/core5/http/impl/io/IdentityOutputStream.java  | 4 ++--
 .../apache/hc/core5/reactor/AbstractSingleCoreIOReactor.java    | 5 +++++
 .../java/org/apache/hc/core5/reactor/MultiCoreIOReactor.java    | 5 +++++
 10 files changed, 29 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/635aad7b/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 48ffd54..d55f155 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -48,6 +48,9 @@ adds several incremental improvements.
   
 * HTTPCORE-548: Add missing HttpContext parameter to APIs.
   Contributed by Gary Gregory <ggregory at apache.org>
+  
+* Refactor duplicate messages into a new 0-arg constructor for org.apache.hc.core5.http.StreamClosedException.
+  Contributed by Gary Gregory <ggregory at apache.org>
 
 Release 5.0-BETA2
 -------------------

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/635aad7b/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java b/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java
index 2d16700..abf2406 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java
@@ -36,6 +36,10 @@ import java.io.IOException;
  */
 public class StreamClosedException extends IOException {
 
+    public StreamClosedException() {
+        super("Stream already closed");
+    }
+
     public StreamClosedException(final String message) {
         super(message);
     }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/635aad7b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java
index c7ba75b..0fd0360 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java
@@ -138,7 +138,7 @@ public class ChunkedInputStream extends InputStream {
     @Override
     public int read() throws IOException {
         if (this.closed) {
-            throw new StreamClosedException("Stream already closed");
+            throw new StreamClosedException();
         }
         if (this.eof) {
             return -1;
@@ -173,7 +173,7 @@ public class ChunkedInputStream extends InputStream {
     public int read (final byte[] b, final int off, final int len) throws IOException {
 
         if (closed) {
-            throw new StreamClosedException("Stream already closed");
+            throw new StreamClosedException();
         }
 
         if (eof) {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/635aad7b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedOutputStream.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedOutputStream.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedOutputStream.java
index 502ffbf..91a0790 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedOutputStream.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedOutputStream.java
@@ -173,7 +173,7 @@ public class ChunkedOutputStream extends OutputStream {
     @Override
     public void write(final int b) throws IOException {
         if (this.closed) {
-            throw new StreamClosedException("Stream already closed");
+            throw new StreamClosedException();
         }
         this.cache[this.cachePosition] = (byte) b;
         this.cachePosition++;
@@ -198,7 +198,7 @@ public class ChunkedOutputStream extends OutputStream {
     @Override
     public void write(final byte[] src, final int off, final int len) throws IOException {
         if (this.closed) {
-            throw new StreamClosedException("Stream already closed");
+            throw new StreamClosedException();
         }
         if (len >= this.cache.length - this.cachePosition) {
             flushCacheWithAppend(src, off, len);

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/635aad7b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthInputStream.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthInputStream.java
index ae5c491..bc6ce4c 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthInputStream.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthInputStream.java
@@ -125,7 +125,7 @@ public class ContentLengthInputStream extends InputStream {
     @Override
     public int read() throws IOException {
         if (closed) {
-            throw new StreamClosedException("Stream already closed");
+            throw new StreamClosedException();
         }
 
         if (pos >= contentLength) {
@@ -159,7 +159,7 @@ public class ContentLengthInputStream extends InputStream {
     @Override
     public int read(final byte[] b, final int off, final int len) throws java.io.IOException {
         if (closed) {
-            throw new StreamClosedException("Stream already closed");
+            throw new StreamClosedException();
         }
 
         if (pos >= contentLength) {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/635aad7b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthOutputStream.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthOutputStream.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthOutputStream.java
index 174fb61..1f4d398 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthOutputStream.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthOutputStream.java
@@ -102,7 +102,7 @@ public class ContentLengthOutputStream extends OutputStream {
     @Override
     public void write(final byte[] b, final int off, final int len) throws IOException {
         if (this.closed) {
-            throw new StreamClosedException("Stream already closed");
+            throw new StreamClosedException();
         }
         if (this.total < this.contentLength) {
             final long max = this.contentLength - this.total;
@@ -123,7 +123,7 @@ public class ContentLengthOutputStream extends OutputStream {
     @Override
     public void write(final int b) throws IOException {
         if (this.closed) {
-            throw new StreamClosedException("Stream already closed");
+            throw new StreamClosedException();
         }
         if (this.total < this.contentLength) {
             this.buffer.write(b, this.outputStream);

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/635aad7b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityInputStream.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityInputStream.java
index 4326fec..1dfd614 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityInputStream.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityInputStream.java
@@ -82,7 +82,7 @@ public class IdentityInputStream extends InputStream {
     @Override
     public int read() throws IOException {
         if (this.closed) {
-            throw new StreamClosedException("Stream already closed");
+            throw new StreamClosedException();
         }
         return this.buffer.read(this.inputStream);
     }
@@ -90,7 +90,7 @@ public class IdentityInputStream extends InputStream {
     @Override
     public int read(final byte[] b, final int off, final int len) throws IOException {
         if (this.closed) {
-            throw new StreamClosedException("Stream already closed");
+            throw new StreamClosedException();
         }
         return this.buffer.read(b, off, len, this.inputStream);
     }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/635aad7b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityOutputStream.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityOutputStream.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityOutputStream.java
index fc15850..12246b3 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityOutputStream.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/IdentityOutputStream.java
@@ -87,7 +87,7 @@ public class IdentityOutputStream extends OutputStream {
     @Override
     public void write(final byte[] b, final int off, final int len) throws IOException {
         if (this.closed) {
-            throw new StreamClosedException("Stream already closed");
+            throw new StreamClosedException();
         }
         this.buffer.write(b, off, len, this.outputStream);
     }
@@ -100,7 +100,7 @@ public class IdentityOutputStream extends OutputStream {
     @Override
     public void write(final int b) throws IOException {
         if (this.closed) {
-            throw new StreamClosedException("Stream already closed");
+            throw new StreamClosedException();
         }
         this.buffer.write(b, this.outputStream);
     }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/635aad7b/httpcore5/src/main/java/org/apache/hc/core5/reactor/AbstractSingleCoreIOReactor.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/AbstractSingleCoreIOReactor.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/AbstractSingleCoreIOReactor.java
index 279222d..224a45c 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/AbstractSingleCoreIOReactor.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/AbstractSingleCoreIOReactor.java
@@ -165,4 +165,9 @@ abstract class AbstractSingleCoreIOReactor implements IOReactor {
         close(CloseMode.GRACEFUL);
     }
 
+    @Override
+    public String toString() {
+        return super.toString() + " [status=" + status + "]";
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/635aad7b/httpcore5/src/main/java/org/apache/hc/core5/reactor/MultiCoreIOReactor.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/MultiCoreIOReactor.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/MultiCoreIOReactor.java
index 114ae94..078a76f 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/MultiCoreIOReactor.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/MultiCoreIOReactor.java
@@ -134,4 +134,9 @@ class MultiCoreIOReactor implements IOReactor {
         close(CloseMode.GRACEFUL);
     }
 
+    @Override
+    public String toString() {
+        return super.toString() + " [status=" + status + "]";
+    }
+
 }