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/13 23:10:50 UTC
httpcomponents-core git commit: Better exception messages.
Repository: httpcomponents-core
Updated Branches:
refs/heads/4.4.x 553892e6f -> 505e3feae
Better exception messages.
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/505e3fea
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/505e3fea
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/505e3fea
Branch: refs/heads/4.4.x
Commit: 505e3feaebb0e58935b790f6f068158fa969ac70
Parents: 553892e
Author: Gary Gregory <ga...@gmail.com>
Authored: Mon Aug 13 17:10:46 2018 -0600
Committer: Gary Gregory <ga...@gmail.com>
Committed: Mon Aug 13 17:10:46 2018 -0600
----------------------------------------------------------------------
.../org/apache/http/impl/nio/codecs/ChunkDecoder.java | 6 +++---
.../java/org/apache/http/TruncatedChunkException.java | 10 ++++++++++
.../java/org/apache/http/impl/io/ChunkedInputStream.java | 5 ++---
.../apache/http/impl/io/ContentLengthOutputStream.java | 4 ++--
4 files changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/505e3fea/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkDecoder.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkDecoder.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkDecoder.java
index ede54dd..a6c0fea 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkDecoder.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/ChunkDecoder.java
@@ -223,9 +223,9 @@ public class ChunkDecoder extends AbstractContentDecoder {
if (!this.buffer.hasData() && this.endOfStream) {
this.state = COMPLETED;
this.completed = true;
- throw new TruncatedChunkException("Truncated chunk "
- + "( expected size: " + this.chunkSize
- + "; actual size: " + this.pos + ")");
+ throw new TruncatedChunkException(
+ "Truncated chunk (expected size: %,d; actual size: %,d)",
+ chunkSize, pos);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/505e3fea/httpcore/src/main/java/org/apache/http/TruncatedChunkException.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/TruncatedChunkException.java b/httpcore/src/main/java/org/apache/http/TruncatedChunkException.java
index 0458f8e..4ff9c3b 100644
--- a/httpcore/src/main/java/org/apache/http/TruncatedChunkException.java
+++ b/httpcore/src/main/java/org/apache/http/TruncatedChunkException.java
@@ -45,4 +45,14 @@ public class TruncatedChunkException extends MalformedChunkCodingException {
super(message);
}
+ /**
+ * Constructs a new TruncatedChunkException with the specified detail message.
+ *
+ * @param format The exception detail message format; see {@link String#format(String, Object...)}.
+ * @param args The exception detail message arguments; see {@link String#format(String, Object...)}.
+ */
+ public TruncatedChunkException(final String format, final Object... args) {
+ super(HttpException.clean(String.format(format, args)));
+ }
+
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/505e3fea/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java b/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
index f4f62fa..5165b7d 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
@@ -195,9 +195,8 @@ public class ChunkedInputStream extends InputStream {
return readLen;
}
eof = true;
- throw new TruncatedChunkException("Truncated chunk "
- + "( expected size: " + chunkSize
- + "; actual size: " + pos + ")");
+ throw new TruncatedChunkException("Truncated chunk (expected size: %,d; actual size: %,d)",
+ chunkSize, pos);
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/505e3fea/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthOutputStream.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthOutputStream.java b/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthOutputStream.java
index 184c917..3dc10bd 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthOutputStream.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthOutputStream.java
@@ -60,10 +60,10 @@ public class ContentLengthOutputStream extends OutputStream {
private final long contentLength;
/** Total bytes written */
- private long total = 0;
+ private long total;
/** True if the stream is closed. */
- private boolean closed = false;
+ private boolean closed;
/**
* Wraps a session output buffer and cuts off output after a defined number