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 2018/08/14 07:51:36 UTC
[01/12] httpcomponents-core git commit: Fix typos in exception
messages. [Forced Update!]
Repository: httpcomponents-core
Updated Branches:
refs/heads/4.4.x e2485e3c5 -> 14e3a19a9 (forced update)
Fix typos in 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/fd3ca030
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/fd3ca030
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/fd3ca030
Branch: refs/heads/4.4.x
Commit: fd3ca030f7238f5f79da09455f0dde4aa2976ba2
Parents: d83917a
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Aug 3 10:55:11 2018 -0600
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue Aug 14 09:49:27 2018 +0200
----------------------------------------------------------------------
RELEASE_NOTES.txt | 4 ++++
.../apache/http/impl/nio/codecs/LengthDelimitedDecoder.java | 4 ++--
.../java/org/apache/http/impl/io/ContentLengthInputStream.java | 6 +++---
3 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fd3ca030/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 0995b89..6ebc2db 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -7,6 +7,10 @@ Changelog
-------------------
* Refactor duplicate messages into a new 0-arg constructor for org.apache.http.ConnectionClosedException.
+ Contributed by Gary Gregory <ggregory at apache.org>
+
+* Fix typos in exception messages.
+ Contributed by Gary Gregory <ggregory at apache.org>
Release 4.4.10
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fd3ca030/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
index d1a6710..64e223a 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
@@ -88,7 +88,7 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
if (this.len < this.contentLength) {
throw new ConnectionClosedException(
"Premature end of Content-Length delimited message body (expected: "
- + this.contentLength + "; received: " + this.len);
+ + this.contentLength + "; received: " + this.len + ")");
}
}
this.len += bytesRead;
@@ -141,7 +141,7 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
if (this.len < this.contentLength) {
throw new ConnectionClosedException(
"Premature end of Content-Length delimited message body (expected: "
- + this.contentLength + "; received: " + this.len);
+ + this.contentLength + "; received: " + this.len + ")");
}
}
this.len += bytesRead;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fd3ca030/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java b/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
index 5291175..716df8d 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
@@ -139,7 +139,7 @@ public class ContentLengthInputStream extends InputStream {
if (pos < contentLength) {
throw new ConnectionClosedException(
"Premature end of Content-Length delimited message body (expected: "
- + contentLength + "; received: " + pos);
+ + contentLength + "; received: " + pos + ")");
}
} else {
pos++;
@@ -160,7 +160,7 @@ public class ContentLengthInputStream extends InputStream {
* @throws java.io.IOException Should an error occur on the wrapped stream.
*/
@Override
- public int read (final byte[] b, final int off, final int len) throws java.io.IOException {
+ public int read(final byte[] b, final int off, final int len) throws java.io.IOException {
if (closed) {
throw new IOException("Attempted read from closed stream.");
}
@@ -177,7 +177,7 @@ public class ContentLengthInputStream extends InputStream {
if (count == -1 && pos < contentLength) {
throw new ConnectionClosedException(
"Premature end of Content-Length delimited message body (expected: "
- + contentLength + "; received: " + pos);
+ + contentLength + "; received: " + pos + ")");
}
if (count > 0) {
pos += count;
[12/12] httpcomponents-core git commit: Better formatting of
exception message.
Posted by ol...@apache.org.
Better formatting of exception message.
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/9bfbbb41
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/9bfbbb41
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/9bfbbb41
Branch: refs/heads/4.4.x
Commit: 9bfbbb41f0d5db4e499ace6a50300560e19a8fad
Parents: 4592ae6
Author: Gary Gregory <ga...@gmail.com>
Authored: Mon Aug 13 21:53:03 2018 -0600
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue Aug 14 09:49:35 2018 +0200
----------------------------------------------------------------------
.../apache/http/impl/nio/codecs/IdentityDecoder.java | 4 ++--
.../http/impl/nio/codecs/LengthDelimitedDecoder.java | 4 ++--
.../http/nio/protocol/BasicAsyncRequestConsumer.java | 2 +-
.../http/nio/protocol/BasicAsyncResponseConsumer.java | 2 +-
.../java/org/apache/http/ContentTooLongException.java | 12 ++++++++++++
5 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9bfbbb41/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
index 461263a..e948452 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
@@ -98,8 +98,8 @@ public class IdentityDecoder extends AbstractContentDecoder
} else {
if (this.channel.isOpen()) {
if (position > dst.size()) {
- throw new IOException("Position past end of file [" + position +
- " > " + dst.size() + "]");
+ throw new IOException(String.format("Position past end of file [%,d > %,d]",
+ position, dst.size()));
}
bytesRead = dst.transferFrom(this.channel, position, count);
if (count > 0 && bytesRead == 0) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9bfbbb41/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
index 2df2f45..93d2065 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
@@ -121,8 +121,8 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
} else {
if (this.channel.isOpen()) {
if (position > dst.size()) {
- throw new IOException("Position past end of file [" + position +
- " > " + dst.size() + "]");
+ throw new IOException(String.format("Position past end of file [%,d > %,d]",
+ position, dst.size()));
}
bytesRead = dst.transferFrom(this.channel, position, count < chunk ? count : chunk);
} else {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9bfbbb41/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestConsumer.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestConsumer.java b/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestConsumer.java
index 9508506..9524169 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestConsumer.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncRequestConsumer.java
@@ -69,7 +69,7 @@ public class BasicAsyncRequestConsumer extends AbstractAsyncRequestConsumer<Http
final HttpEntity entity, final ContentType contentType) throws IOException {
long len = entity.getContentLength();
if (len > Integer.MAX_VALUE) {
- throw new ContentTooLongException("Entity content is too long: " + len);
+ throw new ContentTooLongException("Entity content is too long: %,d", len);
}
if (len < 0) {
len = 4096;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9bfbbb41/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseConsumer.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseConsumer.java b/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseConsumer.java
index a42aaa6..66fd4e3 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseConsumer.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/protocol/BasicAsyncResponseConsumer.java
@@ -68,7 +68,7 @@ public class BasicAsyncResponseConsumer extends AbstractAsyncResponseConsumer<Ht
final HttpEntity entity, final ContentType contentType) throws IOException {
long len = entity.getContentLength();
if (len > Integer.MAX_VALUE) {
- throw new ContentTooLongException("Entity content is too long: " + len);
+ throw new ContentTooLongException("Entity content is too long: %,d", len);
}
if (len < 0) {
len = 4096;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9bfbbb41/httpcore/src/main/java/org/apache/http/ContentTooLongException.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/ContentTooLongException.java b/httpcore/src/main/java/org/apache/http/ContentTooLongException.java
index f7020ac..c8ca10f 100644
--- a/httpcore/src/main/java/org/apache/http/ContentTooLongException.java
+++ b/httpcore/src/main/java/org/apache/http/ContentTooLongException.java
@@ -47,4 +47,16 @@ public class ContentTooLongException extends IOException {
super(message);
}
+ /**
+ * Constructs a new ContentTooLongException 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...)}.
+ *
+ * @since 4.4.11
+ */
+ public ContentTooLongException(final String format, final Object... args) {
+ super(HttpException.clean(String.format(format, args)));
+ }
+
}
[09/12] httpcomponents-core git commit: Remove redundant
super-interfaces. Access static methods directly. Remove unnecessary
@SuppressWarnings. Remove exceptions not thrown from private method
signatures.
Posted by ol...@apache.org.
Remove redundant super-interfaces. Access static methods directly.
Remove unnecessary @SuppressWarnings. Remove exceptions not thrown from
private method signatures.
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/2bfa5959
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/2bfa5959
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/2bfa5959
Branch: refs/heads/4.4.x
Commit: 2bfa595975f0c8bab2fccb1e1bbe5c350f0b1918
Parents: fd3ca03
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 09:59:03 2018 -0600
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue Aug 14 09:49:35 2018 +0200
----------------------------------------------------------------------
.../http/nio/protocol/HttpAsyncService.java | 4 +-
.../impl/nio/codecs/TestHttpMessageParser.java | 7 +--
.../nio/reactor/TestSessionInOutBuffers.java | 7 +--
.../apache/http/nio/pool/TestNIOConnPool.java | 1 -
.../TestBasicAsyncClientExchangeHandler.java | 4 +-
.../nio/protocol/TestHttpAsyncRequester.java | 5 +-
.../http/nio/protocol/TestHttpAsyncService.java | 1 -
.../http/nio/testserver/HttpClientNio.java | 1 -
.../http/nio/testserver/HttpServerNio.java | 2 +-
.../main/java/org/apache/http/HttpVersion.java | 6 +--
.../org/apache/http/entity/ByteArrayEntity.java | 2 -
.../apache/http/impl/BHttpConnectionBase.java | 3 +-
.../http/impl/TestBHttpConnectionBase.java | 23 ++++----
.../apache/http/impl/io/TestRequestParser.java | 4 +-
.../apache/http/impl/io/TestResponseParser.java | 4 +-
.../http/impl/io/TestSessionInOutBuffers.java | 9 ++--
.../java/org/apache/http/pool/TestConnPool.java | 57 ++++++++++----------
.../apache/http/pool/TestRouteSpecificPool.java | 3 --
.../http/protocol/TestHttpRequestExecutor.java | 9 ++--
.../apache/http/protocol/TestHttpService.java | 5 +-
20 files changed, 70 insertions(+), 87 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java b/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
index 59e3080..a7cb2a6 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/protocol/HttpAsyncService.java
@@ -688,7 +688,7 @@ public class HttpAsyncService implements NHttpServerEventHandler {
private void completeRequest(
final Incoming incoming,
final NHttpServerConnection conn,
- final State state) throws IOException, HttpException {
+ final State state) throws IOException {
state.setRequestState(MessageState.READY);
state.setIncoming(null);
@@ -743,7 +743,7 @@ public class HttpAsyncService implements NHttpServerEventHandler {
private void completeResponse(
final Outgoing outgoing,
final NHttpServerConnection conn,
- final State state) throws IOException, HttpException {
+ final State state) throws IOException {
final HttpContext context = outgoing.getContext();
final HttpResponse response = outgoing.getResponse();
final HttpAsyncResponseProducer responseProducer = outgoing.getProducer();
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java b/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java
index 4f6b8e7..0b0caed 100644
--- a/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java
+++ b/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestHttpMessageParser.java
@@ -29,7 +29,6 @@ package org.apache.http.impl.nio.codecs;
import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.Charset;
@@ -51,13 +50,11 @@ import org.junit.Test;
*/
public class TestHttpMessageParser {
- private static ReadableByteChannel newChannel(final String s, final Charset charset)
- throws UnsupportedEncodingException {
+ private static ReadableByteChannel newChannel(final String s, final Charset charset) {
return Channels.newChannel(new ByteArrayInputStream(s.getBytes(charset)));
}
- private static ReadableByteChannel newChannel(final String s)
- throws UnsupportedEncodingException {
+ private static ReadableByteChannel newChannel(final String s) {
return newChannel(s, Consts.ASCII);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java b/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java
index 89f6c54..d4e9b95 100644
--- a/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java
+++ b/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java
@@ -29,7 +29,6 @@ package org.apache.http.impl.nio.reactor;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
@@ -86,13 +85,11 @@ public class TestSessionInOutBuffers {
return Channels.newChannel(new ByteArrayInputStream(bytes));
}
- private static ReadableByteChannel newChannel(final String s, final Charset charset)
- throws UnsupportedEncodingException {
+ private static ReadableByteChannel newChannel(final String s, final Charset charset) {
return Channels.newChannel(new ByteArrayInputStream(s.getBytes(charset)));
}
- private static ReadableByteChannel newChannel(final String s)
- throws UnsupportedEncodingException {
+ private static ReadableByteChannel newChannel(final String s) {
return newChannel(s, Consts.ASCII);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java b/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
index e64a6d3..d1b1953 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
@@ -320,7 +320,6 @@ public class TestNIOConnPool {
Mockito.when(sessionRequest.getAttachment()).thenReturn("somehost");
Mockito.when(sessionRequest.getException()).thenReturn(new IOException());
final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- @SuppressWarnings("unchecked")
final SocketAddressResolver<String> addressResolver = Mockito.mock(SocketAddressResolver.class);
Mockito.when(addressResolver.resolveRemoteAddress("somehost")).thenThrow(new UnknownHostException());
final LocalSessionPool pool = new LocalSessionPool(ioreactor, addressResolver, 2, 10);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncClientExchangeHandler.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncClientExchangeHandler.java b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncClientExchangeHandler.java
index c04cbfb..f5e895e 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncClientExchangeHandler.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncClientExchangeHandler.java
@@ -46,6 +46,7 @@ import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Matchers;
import org.mockito.Mockito;
public class TestBasicAsyncClientExchangeHandler {
@@ -60,7 +61,6 @@ public class TestBasicAsyncClientExchangeHandler {
private ContentEncoder encoder;
private ContentDecoder decoder;
- @SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
this.requestProducer = Mockito.mock(HttpAsyncRequestProducer.class);
@@ -343,7 +343,7 @@ public class TestBasicAsyncClientExchangeHandler {
@Test
public void testInputTerminated() throws Exception {
this.exchangeHandler.inputTerminated();
- Mockito.verify(this.responseConsumer).failed(Mockito.<ConnectionClosedException>any());
+ Mockito.verify(this.responseConsumer).failed(Matchers.<ConnectionClosedException>any());
try {
this.exchangeHandler.getFuture().get();
Assert.fail("ExecutionException expected");
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java
index 93b079d..ff9f753 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncRequester.java
@@ -63,7 +63,6 @@ public class TestHttpAsyncRequester {
private FutureCallback<Object> callback;
private ConnPool<HttpHost, PoolEntry<HttpHost, NHttpClientConnection>> connPool;
- @SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
this.httpProcessor = Mockito.mock(HttpProcessor.class);
@@ -191,7 +190,7 @@ public class TestHttpAsyncRequester {
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
+ @SuppressWarnings({ "rawtypes" })
@Test
public void testPooledConnectionRequestFailed() throws Exception {
final HttpHost host = new HttpHost("somehost");
@@ -215,7 +214,7 @@ public class TestHttpAsyncRequester {
Mockito.verify(this.requestProducer).close();
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
+ @SuppressWarnings({ "rawtypes" })
@Test
public void testPooledConnectionRequestCancelled() throws Exception {
final HttpHost host = new HttpHost("somehost");
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
index 235915b..dcb92a6 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestHttpAsyncService.java
@@ -84,7 +84,6 @@ public class TestHttpAsyncService {
private ContentDecoder decoder;
private Cancellable cancellable;
- @SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
this.requestHandler = Mockito.mock(HttpAsyncRequestHandler.class);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore-nio/src/test/java/org/apache/http/nio/testserver/HttpClientNio.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/HttpClientNio.java b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/HttpClientNio.java
index 3e46a57..f6d1173 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/HttpClientNio.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/HttpClientNio.java
@@ -73,7 +73,6 @@ import org.apache.http.protocol.RequestExpectContinue;
import org.apache.http.protocol.RequestTargetHost;
import org.apache.http.protocol.RequestUserAgent;
-@SuppressWarnings("deprecation")
public class HttpClientNio {
public static final HttpProcessor DEFAULT_HTTP_PROC = new ImmutableHttpProcessor(
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore-nio/src/test/java/org/apache/http/nio/testserver/HttpServerNio.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/HttpServerNio.java b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/HttpServerNio.java
index 4126fec..eb8e3c0 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/HttpServerNio.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/HttpServerNio.java
@@ -57,7 +57,7 @@ public class HttpServerNio {
private volatile HttpServer server;
- public HttpServerNio() throws IOException {
+ public HttpServerNio() {
super();
this.reqistry = new UriHttpAsyncRequestHandlerMapper();
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore/src/main/java/org/apache/http/HttpVersion.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/HttpVersion.java b/httpcore/src/main/java/org/apache/http/HttpVersion.java
index 587a4be..79e3638 100644
--- a/httpcore/src/main/java/org/apache/http/HttpVersion.java
+++ b/httpcore/src/main/java/org/apache/http/HttpVersion.java
@@ -27,10 +27,8 @@
package org.apache.http;
-import org.apache.http.annotation.ThreadingBehavior;
import org.apache.http.annotation.Contract;
-
-import java.io.Serializable;
+import org.apache.http.annotation.ThreadingBehavior;
/**
* Represents an HTTP version. HTTP uses a "major.minor" numbering
@@ -46,7 +44,7 @@ import java.io.Serializable;
* @since 4.0
*/
@Contract(threading = ThreadingBehavior.IMMUTABLE)
-public final class HttpVersion extends ProtocolVersion implements Serializable {
+public final class HttpVersion extends ProtocolVersion {
private static final long serialVersionUID = -5856653513894415344L;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java b/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java
index 9e2c113..226e8bd 100644
--- a/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java
+++ b/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java
@@ -52,7 +52,6 @@ public class ByteArrayEntity extends AbstractHttpEntity implements Cloneable {
/**
* @since 4.2
*/
- @SuppressWarnings("deprecation")
public ByteArrayEntity(final byte[] b, final ContentType contentType) {
super();
Args.notNull(b, "Source byte array");
@@ -68,7 +67,6 @@ public class ByteArrayEntity extends AbstractHttpEntity implements Cloneable {
/**
* @since 4.2
*/
- @SuppressWarnings("deprecation")
public ByteArrayEntity(final byte[] b, final int off, final int len, final ContentType contentType) {
super();
Args.notNull(b, "Source byte array");
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java b/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
index c62a027..4176286 100644
--- a/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
+++ b/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
@@ -41,7 +41,6 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.http.ConnectionClosedException;
import org.apache.http.Header;
-import org.apache.http.HttpConnection;
import org.apache.http.HttpConnectionMetrics;
import org.apache.http.HttpEntity;
import org.apache.http.HttpException;
@@ -74,7 +73,7 @@ import org.apache.http.util.NetUtils;
*
* @since 4.0
*/
-public class BHttpConnectionBase implements HttpConnection, HttpInetConnection {
+public class BHttpConnectionBase implements HttpInetConnection {
private final SessionInputBufferImpl inbuffer;
private final SessionOutputBufferImpl outbuffer;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java b/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java
index 705ba74..f966181 100644
--- a/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java
+++ b/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java
@@ -52,6 +52,7 @@ import org.apache.http.message.BasicHttpResponse;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
@@ -126,7 +127,7 @@ public class TestBHttpConnectionBase {
Assert.assertFalse(conn.isOpen());
Mockito.verify(outstream, Mockito.times(1)).write(
- Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt());
+ Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt());
Mockito.verify(socket, Mockito.times(1)).shutdownInput();
Mockito.verify(socket, Mockito.times(1)).shutdownOutput();
Mockito.verify(socket, Mockito.times(1)).close();
@@ -134,7 +135,7 @@ public class TestBHttpConnectionBase {
conn.close();
Mockito.verify(socket, Mockito.times(1)).close();
Mockito.verify(outstream, Mockito.times(1)).write(
- Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt());
+ Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt());
}
@Test
@@ -155,7 +156,7 @@ public class TestBHttpConnectionBase {
Assert.assertFalse(conn.isOpen());
Mockito.verify(outstream, Mockito.never()).write(
- Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt());
+ Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt());
Mockito.verify(socket, Mockito.never()).shutdownInput();
Mockito.verify(socket, Mockito.never()).shutdownOutput();
Mockito.verify(socket, Mockito.times(1)).close();
@@ -252,7 +253,7 @@ public class TestBHttpConnectionBase {
public void testSetSocketTimeoutException() throws Exception {
conn.bind(socket);
- Mockito.doThrow(new SocketException()).when(socket).setSoTimeout(Mockito.anyInt());
+ Mockito.doThrow(new SocketException()).when(socket).setSoTimeout(Matchers.anyInt());
conn.setSocketTimeout(123);
@@ -291,9 +292,9 @@ public class TestBHttpConnectionBase {
Assert.assertTrue(conn.awaitInput(432));
- Mockito.verify(socket, Mockito.never()).setSoTimeout(Mockito.anyInt());
+ Mockito.verify(socket, Mockito.never()).setSoTimeout(Matchers.anyInt());
Mockito.verify(instream, Mockito.times(1)).read(
- Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt());
+ Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt());
}
@Test
@@ -311,14 +312,14 @@ public class TestBHttpConnectionBase {
Mockito.verify(socket, Mockito.times(1)).setSoTimeout(432);
Mockito.verify(socket, Mockito.times(1)).setSoTimeout(345);
Mockito.verify(instream, Mockito.times(1)).read(
- Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt());
+ Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt());
}
@Test
public void testAwaitInputNoData() throws Exception {
final InputStream instream = Mockito.mock(InputStream.class);
Mockito.when(socket.getInputStream()).thenReturn(instream);
- Mockito.when(instream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
+ Mockito.when(instream.read(Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt()))
.thenReturn(-1);
conn.bind(socket);
@@ -351,7 +352,7 @@ public class TestBHttpConnectionBase {
public void testStaleWhenEndOfStream() throws Exception {
final InputStream instream = Mockito.mock(InputStream.class);
Mockito.when(socket.getInputStream()).thenReturn(instream);
- Mockito.when(instream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
+ Mockito.when(instream.read(Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt()))
.thenReturn(-1);
conn.bind(socket);
@@ -364,7 +365,7 @@ public class TestBHttpConnectionBase {
public void testNotStaleWhenTimeout() throws Exception {
final InputStream instream = Mockito.mock(InputStream.class);
Mockito.when(socket.getInputStream()).thenReturn(instream);
- Mockito.when(instream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
+ Mockito.when(instream.read(Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt()))
.thenThrow(new SocketTimeoutException());
conn.bind(socket);
@@ -377,7 +378,7 @@ public class TestBHttpConnectionBase {
public void testStaleWhenIOError() throws Exception {
final InputStream instream = Mockito.mock(InputStream.class);
Mockito.when(socket.getInputStream()).thenReturn(instream);
- Mockito.when(instream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
+ Mockito.when(instream.read(Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt()))
.thenThrow(new SocketException());
conn.bind(socket);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java b/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java
index 82d2892..ad6a050 100644
--- a/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java
+++ b/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java
@@ -111,9 +111,7 @@ public class TestRequestParser {
Assert.assertNotNull(httprequest);
Assert.assertEquals(5, timeoutCount);
- @SuppressWarnings("null") // httprequest cannot be null here
- final
- RequestLine reqline = httprequest.getRequestLine();
+ final RequestLine reqline = httprequest.getRequestLine();
Assert.assertNotNull(reqline);
Assert.assertEquals("GET", reqline.getMethod());
Assert.assertEquals("/", reqline.getUri());
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java b/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java
index 40bedff..5c5fc93 100644
--- a/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java
+++ b/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java
@@ -112,9 +112,7 @@ public class TestResponseParser {
Assert.assertNotNull(httpresponse);
Assert.assertEquals(5, timeoutCount);
- @SuppressWarnings("null") // httpresponse cannot be null here
- final
- StatusLine statusline = httpresponse.getStatusLine();
+ final StatusLine statusline = httpresponse.getStatusLine();
Assert.assertNotNull(statusline);
Assert.assertEquals(200, statusline.getStatusCode());
Assert.assertEquals("OK", statusline.getReasonPhrase());
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java b/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
index 139aa2d..b5cff65 100644
--- a/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
+++ b/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
@@ -42,6 +42,7 @@ import org.apache.http.io.HttpTransportMetrics;
import org.apache.http.util.CharArrayBuffer;
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.Matchers;
import org.mockito.Mockito;
public class TestSessionInOutBuffers {
@@ -339,8 +340,8 @@ public class TestSessionInOutBuffers {
outbuffer.write(new byte[]{3, 4});
outbuffer.flush();
Mockito.verify(outstream, Mockito.times(1)).write(
- Mockito.<byte[]>any(), Mockito.anyInt(), Mockito.anyInt());
- Mockito.verify(outstream, Mockito.never()).write(Mockito.anyInt());
+ Matchers.<byte[]>any(), Matchers.anyInt(), Matchers.anyInt());
+ Mockito.verify(outstream, Mockito.never()).write(Matchers.anyInt());
}
@Test
@@ -352,8 +353,8 @@ public class TestSessionInOutBuffers {
outbuffer.write(new byte[] {1, 2});
outbuffer.write(new byte[]{3, 4});
Mockito.verify(outstream, Mockito.times(2)).write(
- Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt());
- Mockito.verify(outstream, Mockito.times(2)).write(Mockito.anyInt());
+ Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt());
+ Mockito.verify(outstream, Mockito.times(2)).write(Matchers.anyInt());
}
@Test
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java b/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java
index b40806b..e5417a3 100644
--- a/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java
+++ b/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java
@@ -36,6 +36,7 @@ import java.util.concurrent.TimeoutException;
import org.apache.http.HttpConnection;
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.Matchers;
import org.mockito.Mockito;
public class TestConnPool {
@@ -132,8 +133,8 @@ public class TestConnPool {
Mockito.when(conn2.isOpen()).thenReturn(true);
final LocalConnFactory connFactory = Mockito.mock(LocalConnFactory.class);
- Mockito.when(connFactory.create(Mockito.eq("somehost"))).thenReturn(conn1);
- Mockito.when(connFactory.create(Mockito.eq("otherhost"))).thenReturn(conn2);
+ Mockito.when(connFactory.create(Matchers.eq("somehost"))).thenReturn(conn1);
+ Mockito.when(connFactory.create(Matchers.eq("otherhost"))).thenReturn(conn2);
final LocalConnPool pool = new LocalConnPool(connFactory, 2, 10);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
@@ -232,11 +233,11 @@ public class TestConnPool {
final HttpConnection conn1 = Mockito.mock(HttpConnection.class);
Mockito.when(conn1.isOpen()).thenReturn(true);
- Mockito.when(connFactory.create(Mockito.eq("somehost"))).thenReturn(conn1);
+ Mockito.when(connFactory.create(Matchers.eq("somehost"))).thenReturn(conn1);
final HttpConnection conn2 = Mockito.mock(HttpConnection.class);
Mockito.when(conn2.isOpen()).thenReturn(true);
- Mockito.when(connFactory.create(Mockito.eq("otherhost"))).thenReturn(conn2);
+ Mockito.when(connFactory.create(Matchers.eq("otherhost"))).thenReturn(conn2);
final LocalConnPool pool = new LocalConnPool(connFactory, 2, 10);
pool.setMaxPerRoute("somehost", 2);
@@ -311,7 +312,7 @@ public class TestConnPool {
Assert.assertFalse(t8.isDone());
Assert.assertFalse(t9.isDone());
- Mockito.verify(connFactory, Mockito.times(3)).create(Mockito.any(String.class));
+ Mockito.verify(connFactory, Mockito.times(3)).create(Matchers.any(String.class));
pool.release(entry4, true);
pool.release(entry5, false);
@@ -324,7 +325,7 @@ public class TestConnPool {
t9.join();
Assert.assertTrue(future9.isDone());
- Mockito.verify(connFactory, Mockito.times(4)).create(Mockito.any(String.class));
+ Mockito.verify(connFactory, Mockito.times(4)).create(Matchers.any(String.class));
}
@Test
@@ -337,13 +338,13 @@ public class TestConnPool {
Mockito.when(conn2.isOpen()).thenReturn(true);
final HttpConnection conn3 = Mockito.mock(HttpConnection.class);
Mockito.when(conn3.isOpen()).thenReturn(true);
- Mockito.when(connFactory.create(Mockito.eq("somehost"))).thenReturn(conn1, conn2, conn3);
+ Mockito.when(connFactory.create(Matchers.eq("somehost"))).thenReturn(conn1, conn2, conn3);
final HttpConnection conn4 = Mockito.mock(HttpConnection.class);
Mockito.when(conn4.isOpen()).thenReturn(true);
final HttpConnection conn5 = Mockito.mock(HttpConnection.class);
Mockito.when(conn5.isOpen()).thenReturn(true);
- Mockito.when(connFactory.create(Mockito.eq("otherhost"))).thenReturn(conn4, conn5);
+ Mockito.when(connFactory.create(Matchers.eq("otherhost"))).thenReturn(conn4, conn5);
final LocalConnPool pool = new LocalConnPool(connFactory, 2, 10);
pool.setMaxPerRoute("somehost", 2);
@@ -376,8 +377,8 @@ public class TestConnPool {
Assert.assertFalse(t3.isDone());
Assert.assertFalse(t4.isDone());
- Mockito.verify(connFactory, Mockito.times(2)).create(Mockito.eq("somehost"));
- Mockito.verify(connFactory, Mockito.never()).create(Mockito.eq("otherhost"));
+ Mockito.verify(connFactory, Mockito.times(2)).create(Matchers.eq("somehost"));
+ Mockito.verify(connFactory, Mockito.never()).create(Matchers.eq("otherhost"));
PoolStats totals = pool.getTotalStats();
Assert.assertEquals(0, totals.getAvailable());
@@ -395,8 +396,8 @@ public class TestConnPool {
final LocalPoolEntry entry4 = t4.getEntry();
Assert.assertNotNull(entry4);
- Mockito.verify(connFactory, Mockito.times(2)).create(Mockito.eq("somehost"));
- Mockito.verify(connFactory, Mockito.times(2)).create(Mockito.eq("otherhost"));
+ Mockito.verify(connFactory, Mockito.times(2)).create(Matchers.eq("somehost"));
+ Mockito.verify(connFactory, Mockito.times(2)).create(Matchers.eq("otherhost"));
totals = pool.getTotalStats();
Assert.assertEquals(0, totals.getAvailable());
@@ -421,8 +422,8 @@ public class TestConnPool {
final LocalPoolEntry entry6 = t6.getEntry();
Assert.assertNotNull(entry6);
- Mockito.verify(connFactory, Mockito.times(3)).create(Mockito.eq("somehost"));
- Mockito.verify(connFactory, Mockito.times(2)).create(Mockito.eq("otherhost"));
+ Mockito.verify(connFactory, Mockito.times(3)).create(Matchers.eq("somehost"));
+ Mockito.verify(connFactory, Mockito.times(2)).create(Matchers.eq("otherhost"));
totals = pool.getTotalStats();
Assert.assertEquals(0, totals.getAvailable());
@@ -446,7 +447,7 @@ public class TestConnPool {
Mockito.when(conn2.isOpen()).thenReturn(true);
final HttpConnection conn3 = Mockito.mock(HttpConnection.class);
Mockito.when(conn3.isOpen()).thenReturn(true);
- Mockito.when(connFactory.create(Mockito.eq("somehost"))).thenReturn(conn1, conn2, conn3);
+ Mockito.when(connFactory.create(Matchers.eq("somehost"))).thenReturn(conn1, conn2, conn3);
final LocalConnPool pool = new LocalConnPool(connFactory, 2, 10);
pool.setMaxPerRoute("somehost", 2);
@@ -480,7 +481,7 @@ public class TestConnPool {
entry2.setState("some-stuff");
pool.release(entry2, true);
- Mockito.verify(connFactory, Mockito.times(2)).create(Mockito.eq("somehost"));
+ Mockito.verify(connFactory, Mockito.times(2)).create(Matchers.eq("somehost"));
final Future<LocalPoolEntry> future3 = pool.lease("somehost", "some-other-stuff");
final GetPoolEntryThread t3 = new GetPoolEntryThread(future3);
@@ -491,7 +492,7 @@ public class TestConnPool {
final LocalPoolEntry entry3 = t3.getEntry();
Assert.assertNotNull(entry3);
- Mockito.verify(connFactory, Mockito.times(3)).create(Mockito.eq("somehost"));
+ Mockito.verify(connFactory, Mockito.times(3)).create(Matchers.eq("somehost"));
Mockito.verify(conn1).close();
Mockito.verify(conn2, Mockito.never()).close();
@@ -508,7 +509,7 @@ public class TestConnPool {
final HttpConnection conn1 = Mockito.mock(HttpConnection.class);
Mockito.when(conn1.isOpen()).thenReturn(true);
- Mockito.when(connFactory.create(Mockito.eq("somehost"))).thenReturn(conn1);
+ Mockito.when(connFactory.create(Matchers.eq("somehost"))).thenReturn(conn1);
final LocalConnPool pool = new LocalConnPool(connFactory, 2, 2);
@@ -516,7 +517,7 @@ public class TestConnPool {
final LocalPoolEntry entry1 = future1.get(1, TimeUnit.SECONDS);
Assert.assertNotNull(entry1);
- Mockito.verify(connFactory, Mockito.times(1)).create(Mockito.eq("somehost"));
+ Mockito.verify(connFactory, Mockito.times(1)).create(Matchers.eq("somehost"));
entry1.updateExpiry(1, TimeUnit.MILLISECONDS);
pool.release(entry1, true);
@@ -527,7 +528,7 @@ public class TestConnPool {
final LocalPoolEntry entry2 = future2.get(1, TimeUnit.SECONDS);
Assert.assertNotNull(entry2);
- Mockito.verify(connFactory, Mockito.times(2)).create(Mockito.eq("somehost"));
+ Mockito.verify(connFactory, Mockito.times(2)).create(Matchers.eq("somehost"));
final PoolStats totals = pool.getTotalStats();
Assert.assertEquals(0, totals.getAvailable());
@@ -547,7 +548,7 @@ public class TestConnPool {
final HttpConnection conn2 = Mockito.mock(HttpConnection.class);
Mockito.when(conn2.isOpen()).thenReturn(Boolean.TRUE);
- Mockito.when(connFactory.create(Mockito.eq("somehost"))).thenReturn(conn1, conn2);
+ Mockito.when(connFactory.create(Matchers.eq("somehost"))).thenReturn(conn1, conn2);
final LocalConnPool pool = new LocalConnPool(connFactory, 2, 2);
@@ -585,7 +586,7 @@ public class TestConnPool {
final HttpConnection conn1 = Mockito.mock(HttpConnection.class);
Mockito.when(conn1.isOpen()).thenReturn(true);
- Mockito.when(connFactory.create(Mockito.eq("somehost"))).thenReturn(conn1);
+ Mockito.when(connFactory.create(Matchers.eq("somehost"))).thenReturn(conn1);
final LocalConnPool pool = new LocalConnPool(connFactory, 1, 1);
@@ -632,7 +633,7 @@ public class TestConnPool {
final HttpConnection conn1 = Mockito.mock(HttpConnection.class);
Mockito.when(conn1.isOpen()).thenReturn(true);
- Mockito.when(connFactory.create(Mockito.eq("somehost"))).thenReturn(conn1);
+ Mockito.when(connFactory.create(Matchers.eq("somehost"))).thenReturn(conn1);
final LocalConnPool pool = new LocalConnPool(connFactory, 1, 1);
@@ -671,7 +672,7 @@ public class TestConnPool {
final HttpConnection conn2 = Mockito.mock(HttpConnection.class);
Mockito.when(conn2.isOpen()).thenReturn(true);
- Mockito.when(connFactory.create(Mockito.eq("somehost"))).thenReturn(conn1, conn2);
+ Mockito.when(connFactory.create(Matchers.eq("somehost"))).thenReturn(conn1, conn2);
final LocalConnPool pool = new LocalConnPool(connFactory, 2, 2);
@@ -767,10 +768,10 @@ public class TestConnPool {
final HttpConnection conn1 = Mockito.mock(HttpConnection.class);
Mockito.when(conn1.isOpen()).thenReturn(true);
- Mockito.when(connFactory.create(Mockito.eq("somehost"))).thenReturn(conn1);
+ Mockito.when(connFactory.create(Matchers.eq("somehost"))).thenReturn(conn1);
final HttpConnection conn2 = Mockito.mock(HttpConnection.class);
Mockito.when(conn2.isOpen()).thenReturn(true);
- Mockito.when(connFactory.create(Mockito.eq("otherhost"))).thenReturn(conn2);
+ Mockito.when(connFactory.create(Matchers.eq("otherhost"))).thenReturn(conn2);
final LocalConnPool pool = new LocalConnPool(connFactory, 2, 2);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
@@ -810,7 +811,7 @@ public class TestConnPool {
Mockito.when(conn.isStale()).thenReturn(false);
final LocalConnFactory connFactory = Mockito.mock(LocalConnFactory.class);
- Mockito.when(connFactory.create(Mockito.eq("somehost"))).thenReturn(conn);
+ Mockito.when(connFactory.create(Matchers.eq("somehost"))).thenReturn(conn);
final LocalConnPool pool = new LocalConnPool(connFactory, 2, 10);
pool.setValidateAfterInactivity(100);
@@ -838,7 +839,7 @@ public class TestConnPool {
Mockito.when(conn.isStale()).thenReturn(false);
final LocalConnFactory connFactory = Mockito.mock(LocalConnFactory.class);
- Mockito.when(connFactory.create(Mockito.eq("somehost"))).thenReturn(conn);
+ Mockito.when(connFactory.create(Matchers.eq("somehost"))).thenReturn(conn);
final LocalConnPool pool = new LocalConnPool(connFactory, 2, 10);
pool.setValidateAfterInactivity(5);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore/src/test/java/org/apache/http/pool/TestRouteSpecificPool.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/pool/TestRouteSpecificPool.java b/httpcore/src/test/java/org/apache/http/pool/TestRouteSpecificPool.java
index 3e48c5e..7af708f 100644
--- a/httpcore/src/test/java/org/apache/http/pool/TestRouteSpecificPool.java
+++ b/httpcore/src/test/java/org/apache/http/pool/TestRouteSpecificPool.java
@@ -278,9 +278,7 @@ public class TestRouteSpecificPool {
@Test
public void testWaitingThreadQueuing() throws Exception {
final LocalRoutePool pool = new LocalRoutePool();
- @SuppressWarnings("unchecked")
final Future<LocalPoolEntry> future1 = Mockito.mock(Future.class);
- @SuppressWarnings("unchecked")
final Future<LocalPoolEntry> future2 = Mockito.mock(Future.class);
Assert.assertEquals(0, pool.getPendingCount());
@@ -308,7 +306,6 @@ public class TestRouteSpecificPool {
final HttpConnection conn2 = Mockito.mock(HttpConnection.class);
final LocalPoolEntry entry2 = pool.add(conn2);
- @SuppressWarnings("unchecked")
final Future<LocalPoolEntry> future1 = Mockito.mock(Future.class);
pool.queue(future1);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore/src/test/java/org/apache/http/protocol/TestHttpRequestExecutor.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/protocol/TestHttpRequestExecutor.java b/httpcore/src/test/java/org/apache/http/protocol/TestHttpRequestExecutor.java
index 8370c2a..0b078c3 100644
--- a/httpcore/src/test/java/org/apache/http/protocol/TestHttpRequestExecutor.java
+++ b/httpcore/src/test/java/org/apache/http/protocol/TestHttpRequestExecutor.java
@@ -41,6 +41,7 @@ import org.apache.http.message.BasicHttpRequest;
import org.apache.http.message.BasicHttpResponse;
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.Matchers;
import org.mockito.Mockito;
public class TestHttpRequestExecutor {
@@ -307,7 +308,7 @@ public class TestHttpRequestExecutor {
Mockito.when(conn.receiveResponseHeader()).thenReturn(
new BasicHttpResponse(HttpVersion.HTTP_1_1, 100, "Continue"),
new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK"));
- Mockito.when(conn.isResponseAvailable(Mockito.anyInt())).thenReturn(Boolean.TRUE);
+ Mockito.when(conn.isResponseAvailable(Matchers.anyInt())).thenReturn(Boolean.TRUE);
final HttpResponse response = executor.execute(request, conn, context);
Mockito.verify(conn).sendRequestHeader(request);
@@ -340,7 +341,7 @@ public class TestHttpRequestExecutor {
Mockito.when(conn.receiveResponseHeader()).thenReturn(
new BasicHttpResponse(HttpVersion.HTTP_1_1, 402, "OK"));
- Mockito.when(conn.isResponseAvailable(Mockito.anyInt())).thenReturn(Boolean.TRUE);
+ Mockito.when(conn.isResponseAvailable(Matchers.anyInt())).thenReturn(Boolean.TRUE);
final HttpResponse response = executor.execute(request, conn, context);
Mockito.verify(conn).sendRequestHeader(request);
@@ -371,7 +372,7 @@ public class TestHttpRequestExecutor {
Mockito.when(conn.receiveResponseHeader()).thenReturn(
new BasicHttpResponse(HttpVersion.HTTP_1_1, 101, "OK"));
- Mockito.when(conn.isResponseAvailable(Mockito.anyInt())).thenReturn(Boolean.TRUE);
+ Mockito.when(conn.isResponseAvailable(Matchers.anyInt())).thenReturn(Boolean.TRUE);
try {
executor.execute(request, conn, context);
@@ -399,7 +400,7 @@ public class TestHttpRequestExecutor {
Mockito.when(conn.receiveResponseHeader()).thenReturn(
new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK"));
- Mockito.when(conn.isResponseAvailable(Mockito.anyInt())).thenReturn(Boolean.FALSE);
+ Mockito.when(conn.isResponseAvailable(Matchers.anyInt())).thenReturn(Boolean.FALSE);
final HttpResponse response = executor.execute(request, conn, context);
Mockito.verify(conn).sendRequestHeader(request);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2bfa5959/httpcore/src/test/java/org/apache/http/protocol/TestHttpService.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/protocol/TestHttpService.java b/httpcore/src/test/java/org/apache/http/protocol/TestHttpService.java
index e436fe5..cd60179 100644
--- a/httpcore/src/test/java/org/apache/http/protocol/TestHttpService.java
+++ b/httpcore/src/test/java/org/apache/http/protocol/TestHttpService.java
@@ -47,6 +47,7 @@ import org.apache.http.message.BasicHttpRequest;
import org.apache.http.message.BasicHttpResponse;
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.Matchers;
import org.mockito.Mockito;
public class TestHttpService {
@@ -542,7 +543,7 @@ public class TestHttpService {
Mockito.verify(requestHandler).handle(request, response, context);
Mockito.verify(conn).sendResponseHeader(response);
- Mockito.verify(conn, Mockito.never()).sendResponseEntity(Mockito.<HttpResponse>any());
+ Mockito.verify(conn, Mockito.never()).sendResponseEntity(Matchers.<HttpResponse>any());
Mockito.verify(conn).flush();
Mockito.verify(conn, Mockito.never()).close();
}
@@ -579,7 +580,7 @@ public class TestHttpService {
Mockito.verify(requestHandler).handle(request, response, context);
Mockito.verify(conn).sendResponseHeader(response);
- Mockito.verify(conn, Mockito.never()).sendResponseEntity(Mockito.<HttpResponse>any());
+ Mockito.verify(conn, Mockito.never()).sendResponseEntity(Matchers.<HttpResponse>any());
Mockito.verify(conn).flush();
Mockito.verify(conn, Mockito.never()).close();
}
[07/12] httpcomponents-core git commit: Access completed state via
methods (better for debugging too.)
Posted by ol...@apache.org.
Access completed state via methods (better for debugging too.)
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/5e7de734
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/5e7de734
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/5e7de734
Branch: refs/heads/4.4.x
Commit: 5e7de734e6a1b60a667b201808d01718323ef4c7
Parents: 2548f7c
Author: Gary Gregory <ga...@gmail.com>
Authored: Mon Aug 13 18:07:26 2018 -0600
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue Aug 14 09:49:35 2018 +0200
----------------------------------------------------------------------
.../http/impl/nio/codecs/AbstractContentDecoder.java | 13 +++++++++++++
.../org/apache/http/impl/nio/codecs/ChunkDecoder.java | 6 +++---
.../apache/http/impl/nio/codecs/IdentityDecoder.java | 8 ++++----
.../http/impl/nio/codecs/LengthDelimitedDecoder.java | 14 +++++++-------
4 files changed, 27 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/5e7de734/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
index 0fcbd2c..ec97452 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
@@ -91,6 +91,19 @@ public abstract class AbstractContentDecoder implements ContentDecoder {
}
/**
+ * Sets the completed status of this decoder to true. Normally this is not necessary
+ * (the decoder will automatically complete when the underlying channel
+ * returns EOF). It is useful to mark the decoder as completed if you have
+ * some other means to know all the necessary data has been read and want to
+ * reuse the underlying connection for more messages.
+ *
+ * @since 4.4.11
+ */
+ protected void setCompleted() {
+ this.completed = true;
+ }
+
+ /**
* Reads from the channel to the destination.
*
* @param dst destination.
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/5e7de734/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 5bc3291..77e05dd 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
@@ -222,7 +222,7 @@ public class ChunkDecoder extends AbstractContentDecoder {
} else {
if (!this.buffer.hasData() && this.endOfStream) {
this.state = COMPLETED;
- this.completed = true;
+ setCompleted();
throw new TruncatedChunkException(
"Truncated chunk (expected size: %,d; actual size: %,d)",
chunkSize, pos);
@@ -247,7 +247,7 @@ public class ChunkDecoder extends AbstractContentDecoder {
// Unable to read a footer
if (this.endOfStream) {
this.state = COMPLETED;
- this.completed = true;
+ setCompleted();
}
return totalRead;
}
@@ -259,7 +259,7 @@ public class ChunkDecoder extends AbstractContentDecoder {
parseHeader();
} else {
this.state = COMPLETED;
- this.completed = true;
+ setCompleted();
processFooters();
}
break;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/5e7de734/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
index fddd480..461263a 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
@@ -62,7 +62,7 @@ public class IdentityDecoder extends AbstractContentDecoder
@Override
public int read(final ByteBuffer dst) throws IOException {
Args.notNull(dst, "Byte buffer");
- if (this.completed) {
+ if (isCompleted()) {
return -1;
}
@@ -73,7 +73,7 @@ public class IdentityDecoder extends AbstractContentDecoder
bytesRead = readFromChannel(dst);
}
if (bytesRead == -1) {
- this.completed = true;
+ setCompleted();
}
return bytesRead;
}
@@ -87,7 +87,7 @@ public class IdentityDecoder extends AbstractContentDecoder
if (dst == null) {
return 0;
}
- if (this.completed) {
+ if (isCompleted()) {
return 0;
}
@@ -113,7 +113,7 @@ public class IdentityDecoder extends AbstractContentDecoder
}
}
if (bytesRead == -1) {
- this.completed = true;
+ setCompleted();
}
return bytesRead;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/5e7de734/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
index 1493f3d..2df2f45 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
@@ -71,7 +71,7 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
@Override
public int read(final ByteBuffer dst) throws IOException {
Args.notNull(dst, "Byte buffer");
- if (this.completed) {
+ if (isCompleted()) {
return -1;
}
final int chunk = (int) Math.min((this.contentLength - this.len), Integer.MAX_VALUE);
@@ -84,7 +84,7 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
bytesRead = readFromChannel(dst, chunk);
}
if (bytesRead == -1) {
- this.completed = true;
+ setCompleted();
if (this.len < this.contentLength) {
throw new ConnectionClosedException(
"Premature end of Content-Length delimited message body (expected: %,d; received: %,d)",
@@ -93,9 +93,9 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
}
this.len += bytesRead;
if (this.len >= this.contentLength) {
- this.completed = true;
+ setCompleted();
}
- return this.completed && bytesRead == 0 ? -1 : bytesRead;
+ return isCompleted() && bytesRead == 0 ? -1 : bytesRead;
}
@Override
@@ -107,7 +107,7 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
if (dst == null) {
return 0;
}
- if (this.completed) {
+ if (isCompleted()) {
return -1;
}
@@ -133,7 +133,7 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
}
}
if (bytesRead == -1) {
- this.completed = true;
+ setCompleted();
if (this.len < this.contentLength) {
throw new ConnectionClosedException(
"Premature end of Content-Length delimited message body (expected: %,d; received: %,d)",
@@ -142,7 +142,7 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
}
this.len += bytesRead;
if (this.len >= this.contentLength) {
- this.completed = true;
+ setCompleted();
}
return bytesRead;
}
[05/12] httpcomponents-core git commit: Use camel-case for ivars and
param names; don't nest with else clauses unnecessarily;
comment intention of empty blocks;
use "readLen" name for local var instead of "i" or other cryptic name to hold
read length of
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java-deprecated/org/apache/http/impl/AbstractHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java-deprecated/org/apache/http/impl/AbstractHttpClientConnection.java b/httpcore/src/main/java-deprecated/org/apache/http/impl/AbstractHttpClientConnection.java
index fecec64..6f2b816 100644
--- a/httpcore/src/main/java-deprecated/org/apache/http/impl/AbstractHttpClientConnection.java
+++ b/httpcore/src/main/java-deprecated/org/apache/http/impl/AbstractHttpClientConnection.java
@@ -77,7 +77,7 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
private final EntitySerializer entityserializer;
private final EntityDeserializer entitydeserializer;
- private SessionInputBuffer inbuffer = null;
+ private SessionInputBuffer inBuffer = null;
private SessionOutputBuffer outbuffer = null;
private EofSensor eofSensor = null;
private HttpMessageParser<HttpResponse> responseParser = null;
@@ -212,27 +212,27 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
* methods to initialize HTTP request writer and response parser for this
* connection.
*
- * @param inbuffer the session input buffer.
+ * @param inBuffer the session input buffer.
* @param outbuffer the session output buffer.
* @param params HTTP parameters.
*/
protected void init(
- final SessionInputBuffer inbuffer,
+ final SessionInputBuffer inBuffer,
final SessionOutputBuffer outbuffer,
final HttpParams params) {
- this.inbuffer = Args.notNull(inbuffer, "Input session buffer");
+ this.inBuffer = Args.notNull(inBuffer, "Input session buffer");
this.outbuffer = Args.notNull(outbuffer, "Output session buffer");
- if (inbuffer instanceof EofSensor) {
- this.eofSensor = (EofSensor) inbuffer;
+ if (inBuffer instanceof EofSensor) {
+ this.eofSensor = (EofSensor) inBuffer;
}
this.responseParser = createResponseParser(
- inbuffer,
+ inBuffer,
createHttpResponseFactory(),
params);
this.requestWriter = createRequestWriter(
outbuffer, params);
this.metrics = createConnectionMetrics(
- inbuffer.getMetrics(),
+ inBuffer.getMetrics(),
outbuffer.getMetrics());
}
@@ -240,7 +240,7 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
public boolean isResponseAvailable(final int timeout) throws IOException {
assertOpen();
try {
- return this.inbuffer.isDataAvailable(timeout);
+ return this.inBuffer.isDataAvailable(timeout);
} catch (final SocketTimeoutException ex) {
return false;
}
@@ -295,7 +295,7 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
throws HttpException, IOException {
Args.notNull(response, "HTTP response");
assertOpen();
- final HttpEntity entity = this.entitydeserializer.deserialize(this.inbuffer, response);
+ final HttpEntity entity = this.entitydeserializer.deserialize(this.inBuffer, response);
response.setEntity(entity);
}
@@ -312,7 +312,7 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
return true;
}
try {
- this.inbuffer.isDataAvailable(1);
+ this.inBuffer.isDataAvailable(1);
return isEof();
} catch (final SocketTimeoutException ex) {
return false;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java-deprecated/org/apache/http/impl/AbstractHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java-deprecated/org/apache/http/impl/AbstractHttpServerConnection.java b/httpcore/src/main/java-deprecated/org/apache/http/impl/AbstractHttpServerConnection.java
index 28465a4..04cef17 100644
--- a/httpcore/src/main/java-deprecated/org/apache/http/impl/AbstractHttpServerConnection.java
+++ b/httpcore/src/main/java-deprecated/org/apache/http/impl/AbstractHttpServerConnection.java
@@ -76,7 +76,7 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
private final EntitySerializer entityserializer;
private final EntityDeserializer entitydeserializer;
- private SessionInputBuffer inbuffer = null;
+ private SessionInputBuffer inBuffer = null;
private SessionOutputBuffer outbuffer = null;
private EofSensor eofSensor = null;
private HttpMessageParser<HttpRequest> requestParser = null;
@@ -212,27 +212,27 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
* methods to initialize HTTP request parser and response writer for this
* connection.
*
- * @param inbuffer the session input buffer.
+ * @param inBuffer the session input buffer.
* @param outbuffer the session output buffer.
* @param params HTTP parameters.
*/
protected void init(
- final SessionInputBuffer inbuffer,
+ final SessionInputBuffer inBuffer,
final SessionOutputBuffer outbuffer,
final HttpParams params) {
- this.inbuffer = Args.notNull(inbuffer, "Input session buffer");
+ this.inBuffer = Args.notNull(inBuffer, "Input session buffer");
this.outbuffer = Args.notNull(outbuffer, "Output session buffer");
- if (inbuffer instanceof EofSensor) {
- this.eofSensor = (EofSensor) inbuffer;
+ if (inBuffer instanceof EofSensor) {
+ this.eofSensor = (EofSensor) inBuffer;
}
this.requestParser = createRequestParser(
- inbuffer,
+ inBuffer,
createHttpRequestFactory(),
params);
this.responseWriter = createResponseWriter(
outbuffer, params);
this.metrics = createConnectionMetrics(
- inbuffer.getMetrics(),
+ inBuffer.getMetrics(),
outbuffer.getMetrics());
}
@@ -250,7 +250,7 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
assertOpen();
- final HttpEntity entity = this.entitydeserializer.deserialize(this.inbuffer, request);
+ final HttpEntity entity = this.entitydeserializer.deserialize(this.inBuffer, request);
request.setEntity(entity);
}
@@ -300,7 +300,7 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
return true;
}
try {
- this.inbuffer.isDataAvailable(1);
+ this.inBuffer.isDataAvailable(1);
return isEof();
} catch (final IOException ex) {
return true;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpClientConnection.java b/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpClientConnection.java
index 0d98a88..ac0d97e 100644
--- a/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpClientConnection.java
+++ b/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpClientConnection.java
@@ -83,16 +83,16 @@ public class SocketHttpClientConnection
* @see SocketInputBuffer#SocketInputBuffer(Socket, int, HttpParams)
*
* @param socket the socket.
- * @param buffersize the buffer size.
+ * @param bufferSize the buffer size.
* @param params HTTP parameters.
* @return session input buffer.
* @throws IOException in case of an I/O error.
*/
protected SessionInputBuffer createSessionInputBuffer(
final Socket socket,
- final int buffersize,
+ final int bufferSize,
final HttpParams params) throws IOException {
- return new SocketInputBuffer(socket, buffersize, params);
+ return new SocketInputBuffer(socket, bufferSize, params);
}
/**
@@ -105,16 +105,16 @@ public class SocketHttpClientConnection
* @see SocketOutputBuffer#SocketOutputBuffer(Socket, int, HttpParams)
*
* @param socket the socket.
- * @param buffersize the buffer size.
+ * @param bufferSize the buffer size.
* @param params HTTP parameters.
* @return session output buffer.
* @throws IOException in case of an I/O error.
*/
protected SessionOutputBuffer createSessionOutputBuffer(
final Socket socket,
- final int buffersize,
+ final int bufferSize,
final HttpParams params) throws IOException {
- return new SocketOutputBuffer(socket, buffersize, params);
+ return new SocketOutputBuffer(socket, bufferSize, params);
}
/**
@@ -142,10 +142,10 @@ public class SocketHttpClientConnection
Args.notNull(params, "HTTP parameters");
this.socket = socket;
- final int buffersize = params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
+ final int bufferSize = params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
init(
- createSessionInputBuffer(socket, buffersize, params),
- createSessionOutputBuffer(socket, buffersize, params),
+ createSessionInputBuffer(socket, bufferSize, params),
+ createSessionOutputBuffer(socket, bufferSize, params),
params);
this.open = true;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpServerConnection.java b/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpServerConnection.java
index c343058..dcf190c 100644
--- a/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpServerConnection.java
+++ b/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpServerConnection.java
@@ -74,16 +74,16 @@ public class SocketHttpServerConnection extends
* @see SocketInputBuffer#SocketInputBuffer(Socket, int, HttpParams)
*
* @param socket the socket.
- * @param buffersize the buffer size.
+ * @param bufferSize the buffer size.
* @param params HTTP parameters.
* @return session input buffer.
* @throws IOException in case of an I/O error.
*/
protected SessionInputBuffer createSessionInputBuffer(
final Socket socket,
- final int buffersize,
+ final int bufferSize,
final HttpParams params) throws IOException {
- return new SocketInputBuffer(socket, buffersize, params);
+ return new SocketInputBuffer(socket, bufferSize, params);
}
/**
@@ -96,16 +96,16 @@ public class SocketHttpServerConnection extends
* @see SocketOutputBuffer#SocketOutputBuffer(Socket, int, HttpParams)
*
* @param socket the socket.
- * @param buffersize the buffer size.
+ * @param bufferSize the buffer size.
* @param params HTTP parameters.
* @return session output buffer.
* @throws IOException in case of an I/O error.
*/
protected SessionOutputBuffer createSessionOutputBuffer(
final Socket socket,
- final int buffersize,
+ final int bufferSize,
final HttpParams params) throws IOException {
- return new SocketOutputBuffer(socket, buffersize, params);
+ return new SocketOutputBuffer(socket, bufferSize, params);
}
/**
@@ -131,10 +131,10 @@ public class SocketHttpServerConnection extends
Args.notNull(params, "HTTP parameters");
this.socket = socket;
- final int buffersize = params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
+ final int bufferSize = params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
init(
- createSessionInputBuffer(socket, buffersize, params),
- createSessionOutputBuffer(socket, buffersize, params),
+ createSessionInputBuffer(socket, bufferSize, params),
+ createSessionOutputBuffer(socket, bufferSize, params),
params);
this.open = true;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java-deprecated/org/apache/http/impl/entity/EntityDeserializer.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java-deprecated/org/apache/http/impl/entity/EntityDeserializer.java b/httpcore/src/main/java-deprecated/org/apache/http/impl/entity/EntityDeserializer.java
index f9c8f51..f538e5d 100644
--- a/httpcore/src/main/java-deprecated/org/apache/http/impl/entity/EntityDeserializer.java
+++ b/httpcore/src/main/java-deprecated/org/apache/http/impl/entity/EntityDeserializer.java
@@ -82,14 +82,14 @@ public class EntityDeserializer {
* This method is called by the public
* {@link #deserialize(SessionInputBuffer, HttpMessage)}.
*
- * @param inbuffer the session input buffer.
+ * @param inBuffer the session input buffer.
* @param message the message.
* @return HTTP entity.
* @throws HttpException in case of HTTP protocol violation.
* @throws IOException in case of an I/O error.
*/
protected BasicHttpEntity doDeserialize(
- final SessionInputBuffer inbuffer,
+ final SessionInputBuffer inBuffer,
final HttpMessage message) throws HttpException, IOException {
final BasicHttpEntity entity = new BasicHttpEntity();
@@ -97,15 +97,15 @@ public class EntityDeserializer {
if (len == ContentLengthStrategy.CHUNKED) {
entity.setChunked(true);
entity.setContentLength(-1);
- entity.setContent(new ChunkedInputStream(inbuffer));
+ entity.setContent(new ChunkedInputStream(inBuffer));
} else if (len == ContentLengthStrategy.IDENTITY) {
entity.setChunked(false);
entity.setContentLength(-1);
- entity.setContent(new IdentityInputStream(inbuffer));
+ entity.setContent(new IdentityInputStream(inBuffer));
} else {
entity.setChunked(false);
entity.setContentLength(len);
- entity.setContent(new ContentLengthInputStream(inbuffer, len));
+ entity.setContent(new ContentLengthInputStream(inBuffer, len));
}
final Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
@@ -127,18 +127,18 @@ public class EntityDeserializer {
* <p>
* The content of the entity is NOT retrieved by this method.
*
- * @param inbuffer the session input buffer.
+ * @param inBuffer the session input buffer.
* @param message the message.
* @return HTTP entity.
* @throws HttpException in case of HTTP protocol violation.
* @throws IOException in case of an I/O error.
*/
public HttpEntity deserialize(
- final SessionInputBuffer inbuffer,
+ final SessionInputBuffer inBuffer,
final HttpMessage message) throws HttpException, IOException {
- Args.notNull(inbuffer, "Session input buffer");
+ Args.notNull(inBuffer, "Session input buffer");
Args.notNull(message, "HTTP message");
- return doDeserialize(inbuffer, message);
+ return doDeserialize(inBuffer, message);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java-deprecated/org/apache/http/impl/entity/EntitySerializer.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java-deprecated/org/apache/http/impl/entity/EntitySerializer.java b/httpcore/src/main/java-deprecated/org/apache/http/impl/entity/EntitySerializer.java
index 156734c..cdb6eda 100644
--- a/httpcore/src/main/java-deprecated/org/apache/http/impl/entity/EntitySerializer.java
+++ b/httpcore/src/main/java-deprecated/org/apache/http/impl/entity/EntitySerializer.java
@@ -114,9 +114,9 @@ public class EntitySerializer {
Args.notNull(outbuffer, "Session output buffer");
Args.notNull(message, "HTTP message");
Args.notNull(entity, "HTTP entity");
- final OutputStream outstream = doSerialize(outbuffer, message);
- entity.writeTo(outstream);
- outstream.close();
+ final OutputStream outStream = doSerialize(outbuffer, message);
+ entity.writeTo(outStream);
+ outStream.close();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java-deprecated/org/apache/http/impl/io/AbstractSessionInputBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java-deprecated/org/apache/http/impl/io/AbstractSessionInputBuffer.java b/httpcore/src/main/java-deprecated/org/apache/http/impl/io/AbstractSessionInputBuffer.java
index 6ce8018..533a233 100644
--- a/httpcore/src/main/java-deprecated/org/apache/http/impl/io/AbstractSessionInputBuffer.java
+++ b/httpcore/src/main/java-deprecated/org/apache/http/impl/io/AbstractSessionInputBuffer.java
@@ -64,9 +64,9 @@ import org.apache.http.util.CharArrayBuffer;
@Deprecated
public abstract class AbstractSessionInputBuffer implements SessionInputBuffer, BufferInfo {
- private InputStream instream;
+ private InputStream inStream;
private byte[] buffer;
- private ByteArrayBuffer linebuffer;
+ private ByteArrayBuffer lineBuffer;
private Charset charset;
private boolean ascii;
private int maxLineLen;
@@ -75,8 +75,8 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
private CodingErrorAction onMalformedCharAction;
private CodingErrorAction onUnmappableCharAction;
- private int bufferpos;
- private int bufferlen;
+ private int bufferPos;
+ private int bufferLen;
private CharsetDecoder decoder;
private CharBuffer cbuf;
@@ -86,19 +86,19 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
/**
* Initializes this session input buffer.
*
- * @param instream the source input stream.
- * @param buffersize the size of the internal buffer.
+ * @param inputStream the source input stream.
+ * @param bufferSize the size of the internal buffer.
* @param params HTTP parameters.
*/
- protected void init(final InputStream instream, final int buffersize, final HttpParams params) {
- Args.notNull(instream, "Input stream");
- Args.notNegative(buffersize, "Buffer size");
+ protected void init(final InputStream inputStream, final int bufferSize, final HttpParams params) {
+ Args.notNull(inputStream, "Input stream");
+ Args.notNegative(bufferSize, "Buffer size");
Args.notNull(params, "HTTP parameters");
- this.instream = instream;
- this.buffer = new byte[buffersize];
- this.bufferpos = 0;
- this.bufferlen = 0;
- this.linebuffer = new ByteArrayBuffer(buffersize);
+ this.inStream = inputStream;
+ this.buffer = new byte[bufferSize];
+ this.bufferPos = 0;
+ this.bufferLen = 0;
+ this.lineBuffer = new ByteArrayBuffer(bufferSize);
final String charset = (String) params.getParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET);
this.charset = charset != null ? Charset.forName(charset) : Consts.ASCII;
this.ascii = this.charset.equals(Consts.ASCII);
@@ -134,7 +134,7 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
*/
@Override
public int length() {
- return this.bufferlen - this.bufferpos;
+ return this.bufferLen - this.bufferPos;
}
/**
@@ -147,29 +147,28 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
protected int fillBuffer() throws IOException {
// compact the buffer if necessary
- if (this.bufferpos > 0) {
- final int len = this.bufferlen - this.bufferpos;
+ if (this.bufferPos > 0) {
+ final int len = this.bufferLen - this.bufferPos;
if (len > 0) {
- System.arraycopy(this.buffer, this.bufferpos, this.buffer, 0, len);
+ System.arraycopy(this.buffer, this.bufferPos, this.buffer, 0, len);
}
- this.bufferpos = 0;
- this.bufferlen = len;
+ this.bufferPos = 0;
+ this.bufferLen = len;
}
- final int l;
- final int off = this.bufferlen;
+ final int readLen;
+ final int off = this.bufferLen;
final int len = this.buffer.length - off;
- l = this.instream.read(this.buffer, off, len);
- if (l == -1) {
+ readLen = this.inStream.read(this.buffer, off, len);
+ if (readLen == -1) {
return -1;
- } else {
- this.bufferlen = off + l;
- this.metrics.incrementBytesTransferred(l);
- return l;
}
+ this.bufferLen = off + readLen;
+ this.metrics.incrementBytesTransferred(readLen);
+ return readLen;
}
protected boolean hasBufferedData() {
- return this.bufferpos < this.bufferlen;
+ return this.bufferPos < this.bufferLen;
}
@Override
@@ -181,7 +180,7 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
return -1;
}
}
- return this.buffer[this.bufferpos++] & 0xff;
+ return this.buffer[this.bufferPos++] & 0xff;
}
@Override
@@ -190,32 +189,31 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
return 0;
}
if (hasBufferedData()) {
- final int chunk = Math.min(len, this.bufferlen - this.bufferpos);
- System.arraycopy(this.buffer, this.bufferpos, b, off, chunk);
- this.bufferpos += chunk;
+ final int chunk = Math.min(len, this.bufferLen - this.bufferPos);
+ System.arraycopy(this.buffer, this.bufferPos, b, off, chunk);
+ this.bufferPos += chunk;
return chunk;
}
// If the remaining capacity is big enough, read directly from the
// underlying input stream bypassing the buffer.
if (len > this.minChunkLimit) {
- final int read = this.instream.read(b, off, len);
+ final int read = this.inStream.read(b, off, len);
if (read > 0) {
this.metrics.incrementBytesTransferred(read);
}
return read;
- } else {
- // otherwise read to the buffer first
- while (!hasBufferedData()) {
- final int noRead = fillBuffer();
- if (noRead == -1) {
- return -1;
- }
+ }
+ // otherwise read to the buffer first
+ while (!hasBufferedData()) {
+ final int noRead = fillBuffer();
+ if (noRead == -1) {
+ return -1;
}
- final int chunk = Math.min(len, this.bufferlen - this.bufferpos);
- System.arraycopy(this.buffer, this.bufferpos, b, off, chunk);
- this.bufferpos += chunk;
- return chunk;
}
+ final int chunk = Math.min(len, this.bufferLen - this.bufferPos);
+ System.arraycopy(this.buffer, this.bufferPos, b, off, chunk);
+ this.bufferPos += chunk;
+ return chunk;
}
@Override
@@ -227,7 +225,7 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
}
private int locateLF() {
- for (int i = this.bufferpos; i < this.bufferlen; i++) {
+ for (int i = this.bufferPos; i < this.bufferLen; i++) {
if (this.buffer[i] == HTTP.LF) {
return i;
}
@@ -260,31 +258,31 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
final int i = locateLF();
if (i != -1) {
// end of line found.
- if (this.linebuffer.isEmpty()) {
+ if (this.lineBuffer.isEmpty()) {
// the entire line is preset in the read buffer
return lineFromReadBuffer(charbuffer, i);
}
retry = false;
- final int len = i + 1 - this.bufferpos;
- this.linebuffer.append(this.buffer, this.bufferpos, len);
- this.bufferpos = i + 1;
+ final int len = i + 1 - this.bufferPos;
+ this.lineBuffer.append(this.buffer, this.bufferPos, len);
+ this.bufferPos = i + 1;
} else {
// end of line not found
if (hasBufferedData()) {
- final int len = this.bufferlen - this.bufferpos;
- this.linebuffer.append(this.buffer, this.bufferpos, len);
- this.bufferpos = this.bufferlen;
+ final int len = this.bufferLen - this.bufferPos;
+ this.lineBuffer.append(this.buffer, this.bufferPos, len);
+ this.bufferPos = this.bufferLen;
}
noRead = fillBuffer();
if (noRead == -1) {
retry = false;
}
}
- if (this.maxLineLen > 0 && this.linebuffer.length() >= this.maxLineLen) {
+ if (this.maxLineLen > 0 && this.lineBuffer.length() >= this.maxLineLen) {
throw new IOException("Maximum line length limit exceeded");
}
}
- if (noRead == -1 && this.linebuffer.isEmpty()) {
+ if (noRead == -1 && this.lineBuffer.isEmpty()) {
// indicate the end of stream
return -1;
}
@@ -307,33 +305,33 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
private int lineFromLineBuffer(final CharArrayBuffer charbuffer)
throws IOException {
// discard LF if found
- int len = this.linebuffer.length();
+ int len = this.lineBuffer.length();
if (len > 0) {
- if (this.linebuffer.byteAt(len - 1) == HTTP.LF) {
+ if (this.lineBuffer.byteAt(len - 1) == HTTP.LF) {
len--;
}
// discard CR if found
if (len > 0) {
- if (this.linebuffer.byteAt(len - 1) == HTTP.CR) {
+ if (this.lineBuffer.byteAt(len - 1) == HTTP.CR) {
len--;
}
}
}
if (this.ascii) {
- charbuffer.append(this.linebuffer, 0, len);
+ charbuffer.append(this.lineBuffer, 0, len);
} else {
- final ByteBuffer bbuf = ByteBuffer.wrap(this.linebuffer.buffer(), 0, len);
+ final ByteBuffer bbuf = ByteBuffer.wrap(this.lineBuffer.buffer(), 0, len);
len = appendDecoded(charbuffer, bbuf);
}
- this.linebuffer.clear();
+ this.lineBuffer.clear();
return len;
}
private int lineFromReadBuffer(final CharArrayBuffer charbuffer, final int position)
throws IOException {
- final int off = this.bufferpos;
+ final int off = this.bufferPos;
int i = position;
- this.bufferpos = i + 1;
+ this.bufferPos = i + 1;
if (i > off && this.buffer[i - 1] == HTTP.CR) {
// skip CR if found
i--;
@@ -392,8 +390,8 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
@Override
public String readLine() throws IOException {
final CharArrayBuffer charbuffer = new CharArrayBuffer(64);
- final int l = readLine(charbuffer);
- if (l != -1) {
+ final int readLen = readLine(charbuffer);
+ if (readLen != -1) {
return charbuffer.toString();
} else {
return null;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java-deprecated/org/apache/http/impl/io/AbstractSessionOutputBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java-deprecated/org/apache/http/impl/io/AbstractSessionOutputBuffer.java b/httpcore/src/main/java-deprecated/org/apache/http/impl/io/AbstractSessionOutputBuffer.java
index 38c14de..9537058 100644
--- a/httpcore/src/main/java-deprecated/org/apache/http/impl/io/AbstractSessionOutputBuffer.java
+++ b/httpcore/src/main/java-deprecated/org/apache/http/impl/io/AbstractSessionOutputBuffer.java
@@ -65,7 +65,7 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
private static final byte[] CRLF = new byte[] {HTTP.CR, HTTP.LF};
- private OutputStream outstream;
+ private OutputStream outStream;
private ByteArrayBuffer buffer;
private Charset charset;
private boolean ascii;
@@ -78,17 +78,17 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
private ByteBuffer bbuf;
protected AbstractSessionOutputBuffer(
- final OutputStream outstream,
- final int buffersize,
+ final OutputStream outStream,
+ final int bufferSize,
final Charset charset,
final int minChunkLimit,
final CodingErrorAction malformedCharAction,
final CodingErrorAction unmappableCharAction) {
super();
- Args.notNull(outstream, "Input stream");
- Args.notNegative(buffersize, "Buffer size");
- this.outstream = outstream;
- this.buffer = new ByteArrayBuffer(buffersize);
+ Args.notNull(outStream, "Input stream");
+ Args.notNegative(bufferSize, "Buffer size");
+ this.outStream = outStream;
+ this.buffer = new ByteArrayBuffer(bufferSize);
this.charset = charset != null ? charset : Consts.ASCII;
this.ascii = this.charset.equals(Consts.ASCII);
this.encoder = null;
@@ -103,12 +103,12 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
public AbstractSessionOutputBuffer() {
}
- protected void init(final OutputStream outstream, final int buffersize, final HttpParams params) {
- Args.notNull(outstream, "Input stream");
- Args.notNegative(buffersize, "Buffer size");
+ protected void init(final OutputStream outStream, final int bufferSize, final HttpParams params) {
+ Args.notNull(outStream, "Input stream");
+ Args.notNegative(bufferSize, "Buffer size");
Args.notNull(params, "HTTP parameters");
- this.outstream = outstream;
- this.buffer = new ByteArrayBuffer(buffersize);
+ this.outStream = outStream;
+ this.buffer = new ByteArrayBuffer(bufferSize);
final String charset = (String) params.getParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET);
this.charset = charset != null ? Charset.forName(charset) : Consts.ASCII;
this.ascii = this.charset.equals(Consts.ASCII);
@@ -157,7 +157,7 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
protected void flushBuffer() throws IOException {
final int len = this.buffer.length();
if (len > 0) {
- this.outstream.write(this.buffer.buffer(), 0, len);
+ this.outStream.write(this.buffer.buffer(), 0, len);
this.buffer.clear();
this.metrics.incrementBytesTransferred(len);
}
@@ -166,7 +166,7 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
@Override
public void flush() throws IOException {
flushBuffer();
- this.outstream.flush();
+ this.outStream.flush();
}
@Override
@@ -181,7 +181,7 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
// flush the buffer
flushBuffer();
// write directly to the out stream
- this.outstream.write(b, off, len);
+ this.outStream.write(b, off, len);
this.metrics.incrementBytesTransferred(len);
} else {
// Do not let the buffer grow unnecessarily
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java-deprecated/org/apache/http/impl/io/HttpRequestParser.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java-deprecated/org/apache/http/impl/io/HttpRequestParser.java b/httpcore/src/main/java-deprecated/org/apache/http/impl/io/HttpRequestParser.java
index 5337fb5..553719b 100644
--- a/httpcore/src/main/java-deprecated/org/apache/http/impl/io/HttpRequestParser.java
+++ b/httpcore/src/main/java-deprecated/org/apache/http/impl/io/HttpRequestParser.java
@@ -88,8 +88,8 @@ public class HttpRequestParser extends AbstractMessageParser<HttpMessage> {
throws IOException, HttpException, ParseException {
this.lineBuf.clear();
- final int i = sessionBuffer.readLine(this.lineBuf);
- if (i == -1) {
+ final int readLen = sessionBuffer.readLine(this.lineBuf);
+ if (readLen == -1) {
throw new ConnectionClosedException("Client closed connection");
}
final ParserCursor cursor = new ParserCursor(0, this.lineBuf.length());
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java-deprecated/org/apache/http/impl/io/HttpResponseParser.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java-deprecated/org/apache/http/impl/io/HttpResponseParser.java b/httpcore/src/main/java-deprecated/org/apache/http/impl/io/HttpResponseParser.java
index 0b6399b..e61fbd6 100644
--- a/httpcore/src/main/java-deprecated/org/apache/http/impl/io/HttpResponseParser.java
+++ b/httpcore/src/main/java-deprecated/org/apache/http/impl/io/HttpResponseParser.java
@@ -88,8 +88,8 @@ public class HttpResponseParser extends AbstractMessageParser<HttpMessage> {
throws IOException, HttpException, ParseException {
this.lineBuf.clear();
- final int i = sessionBuffer.readLine(this.lineBuf);
- if (i == -1) {
+ final int readLen = sessionBuffer.readLine(this.lineBuf);
+ if (readLen == -1) {
throw new NoHttpResponseException("The target server failed to respond");
}
//create the status line from the status string
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java-deprecated/org/apache/http/impl/io/SocketInputBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java-deprecated/org/apache/http/impl/io/SocketInputBuffer.java b/httpcore/src/main/java-deprecated/org/apache/http/impl/io/SocketInputBuffer.java
index 246ca0a..b5d8eae 100644
--- a/httpcore/src/main/java-deprecated/org/apache/http/impl/io/SocketInputBuffer.java
+++ b/httpcore/src/main/java-deprecated/org/apache/http/impl/io/SocketInputBuffer.java
@@ -53,7 +53,7 @@ public class SocketInputBuffer extends AbstractSessionInputBuffer implements Eof
* Creates an instance of this class.
*
* @param socket the socket to read data from.
- * @param buffersize the size of the internal buffer. If this number is less
+ * @param bufferSize the size of the internal buffer. If this number is less
* than {@code 0} it is set to the value of
* {@link Socket#getReceiveBufferSize()}. If resultant number is less
* than {@code 1024} it is set to {@code 1024}.
@@ -61,13 +61,13 @@ public class SocketInputBuffer extends AbstractSessionInputBuffer implements Eof
*/
public SocketInputBuffer(
final Socket socket,
- final int buffersize,
+ final int bufferSize,
final HttpParams params) throws IOException {
super();
Args.notNull(socket, "Socket");
this.socket = socket;
this.eof = false;
- int n = buffersize;
+ int n = bufferSize;
if (n < 0) {
n = socket.getReceiveBufferSize();
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java-deprecated/org/apache/http/impl/io/SocketOutputBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java-deprecated/org/apache/http/impl/io/SocketOutputBuffer.java b/httpcore/src/main/java-deprecated/org/apache/http/impl/io/SocketOutputBuffer.java
index 95c63a7..4bb78e5 100644
--- a/httpcore/src/main/java-deprecated/org/apache/http/impl/io/SocketOutputBuffer.java
+++ b/httpcore/src/main/java-deprecated/org/apache/http/impl/io/SocketOutputBuffer.java
@@ -48,7 +48,7 @@ public class SocketOutputBuffer extends AbstractSessionOutputBuffer {
* Creates an instance of this class.
*
* @param socket the socket to write data to.
- * @param buffersize the size of the internal buffer. If this number is less
+ * @param bufferSize the size of the internal buffer. If this number is less
* than {@code 0} it is set to the value of
* {@link Socket#getSendBufferSize()}. If resultant number is less
* than {@code 1024} it is set to {@code 1024}.
@@ -56,11 +56,11 @@ public class SocketOutputBuffer extends AbstractSessionOutputBuffer {
*/
public SocketOutputBuffer(
final Socket socket,
- final int buffersize,
+ final int bufferSize,
final HttpParams params) throws IOException {
super();
Args.notNull(socket, "Socket");
- int n = buffersize;
+ int n = bufferSize;
if (n < 0) {
n = socket.getSendBufferSize();
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/HttpEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/HttpEntity.java b/httpcore/src/main/java/org/apache/http/HttpEntity.java
index 3e4f266..0fa2606 100644
--- a/httpcore/src/main/java/org/apache/http/HttpEntity.java
+++ b/httpcore/src/main/java/org/apache/http/HttpEntity.java
@@ -151,11 +151,11 @@ public interface HttpEntity {
* all allocated resources are properly deallocated when this method
* returns.
*
- * @param outstream the output stream to write entity content to
+ * @param outStream the output stream to write entity content to
*
* @throws IOException if an I/O error occurs
*/
- void writeTo(OutputStream outstream) throws IOException;
+ void writeTo(OutputStream outStream) throws IOException;
/**
* Tells whether this entity depends on an underlying stream.
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java b/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java
index 3695940..71eb32a 100644
--- a/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java
+++ b/httpcore/src/main/java/org/apache/http/entity/BasicHttpEntity.java
@@ -99,25 +99,25 @@ public class BasicHttpEntity extends AbstractHttpEntity {
/**
* Specifies the content.
*
- * @param instream the stream to return with the next call to
+ * @param inStream the stream to return with the next call to
* {@link #getContent getContent}
*/
- public void setContent(final InputStream instream) {
- this.content = instream;
+ public void setContent(final InputStream inStream) {
+ this.content = inStream;
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = getContent();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final InputStream inStream = getContent();
try {
int l;
final byte[] tmp = new byte[OUTPUT_BUFFER_SIZE];
- while ((l = instream.read(tmp)) != -1) {
- outstream.write(tmp, 0, l);
+ while ((l = inStream.read(tmp)) != -1) {
+ outStream.write(tmp, 0, l);
}
} finally {
- instream.close();
+ inStream.close();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java b/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java
index 93dc158..4466aec 100644
--- a/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java
+++ b/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java
@@ -107,12 +107,12 @@ public class BufferedHttpEntity extends HttpEntityWrapper {
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
if (this.buffer != null) {
- outstream.write(this.buffer);
+ outStream.write(this.buffer);
} else {
- super.writeTo(outstream);
+ super.writeTo(outStream);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java b/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java
index 226e8bd..c1d1573 100644
--- a/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java
+++ b/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java
@@ -107,10 +107,10 @@ public class ByteArrayEntity extends AbstractHttpEntity implements Cloneable {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- outstream.write(this.b, this.off, this.len);
- outstream.flush();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ outStream.write(this.b, this.off, this.len);
+ outStream.flush();
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/entity/ContentProducer.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/ContentProducer.java b/httpcore/src/main/java/org/apache/http/entity/ContentProducer.java
index 9cd4e14..dc98ab7 100644
--- a/httpcore/src/main/java/org/apache/http/entity/ContentProducer.java
+++ b/httpcore/src/main/java/org/apache/http/entity/ContentProducer.java
@@ -39,6 +39,6 @@ import java.io.OutputStream;
*/
public interface ContentProducer {
- void writeTo(OutputStream outstream) throws IOException;
+ void writeTo(OutputStream outStream) throws IOException;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/entity/EntityTemplate.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/EntityTemplate.java b/httpcore/src/main/java/org/apache/http/entity/EntityTemplate.java
index 19e49f0..a5a4c24 100644
--- a/httpcore/src/main/java/org/apache/http/entity/EntityTemplate.java
+++ b/httpcore/src/main/java/org/apache/http/entity/EntityTemplate.java
@@ -68,9 +68,9 @@ public class EntityTemplate extends AbstractHttpEntity {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- this.contentproducer.writeTo(outstream);
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ this.contentproducer.writeTo(outStream);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/entity/FileEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/FileEntity.java b/httpcore/src/main/java/org/apache/http/entity/FileEntity.java
index 6ab593a..9ad2210 100644
--- a/httpcore/src/main/java/org/apache/http/entity/FileEntity.java
+++ b/httpcore/src/main/java/org/apache/http/entity/FileEntity.java
@@ -89,18 +89,18 @@ public class FileEntity extends AbstractHttpEntity implements Cloneable {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = new FileInputStream(this.file);
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final InputStream inStream = new FileInputStream(this.file);
try {
final byte[] tmp = new byte[OUTPUT_BUFFER_SIZE];
int l;
- while ((l = instream.read(tmp)) != -1) {
- outstream.write(tmp, 0, l);
+ while ((l = inStream.read(tmp)) != -1) {
+ outStream.write(tmp, 0, l);
}
- outstream.flush();
+ outStream.flush();
} finally {
- instream.close();
+ inStream.close();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/entity/HttpEntityWrapper.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/HttpEntityWrapper.java b/httpcore/src/main/java/org/apache/http/entity/HttpEntityWrapper.java
index 61521bf..6081cbb 100644
--- a/httpcore/src/main/java/org/apache/http/entity/HttpEntityWrapper.java
+++ b/httpcore/src/main/java/org/apache/http/entity/HttpEntityWrapper.java
@@ -89,9 +89,9 @@ public class HttpEntityWrapper implements HttpEntity {
}
@Override
- public void writeTo(final OutputStream outstream)
+ public void writeTo(final OutputStream outStream)
throws IOException {
- wrappedEntity.writeTo(outstream);
+ wrappedEntity.writeTo(outStream);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java b/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java
index 7942bcb..0bd8e49 100644
--- a/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java
+++ b/httpcore/src/main/java/org/apache/http/entity/InputStreamEntity.java
@@ -46,50 +46,50 @@ public class InputStreamEntity extends AbstractHttpEntity {
/**
* Creates an entity with an unknown length.
- * Equivalent to {@code new InputStreamEntity(instream, -1)}.
+ * Equivalent to {@code new InputStreamEntity(inStream, -1)}.
*
- * @param instream input stream
- * @throws IllegalArgumentException if {@code instream} is {@code null}
+ * @param inStream input stream
+ * @throws IllegalArgumentException if {@code inStream} is {@code null}
* @since 4.3
*/
- public InputStreamEntity(final InputStream instream) {
- this(instream, -1);
+ public InputStreamEntity(final InputStream inStream) {
+ this(inStream, -1);
}
/**
* Creates an entity with a specified content length.
*
- * @param instream input stream
+ * @param inStream input stream
* @param length of the input stream, {@code -1} if unknown
- * @throws IllegalArgumentException if {@code instream} is {@code null}
+ * @throws IllegalArgumentException if {@code inStream} is {@code null}
*/
- public InputStreamEntity(final InputStream instream, final long length) {
- this(instream, length, null);
+ public InputStreamEntity(final InputStream inStream, final long length) {
+ this(inStream, length, null);
}
/**
* Creates an entity with a content type and unknown length.
- * Equivalent to {@code new InputStreamEntity(instream, -1, contentType)}.
+ * Equivalent to {@code new InputStreamEntity(inStream, -1, contentType)}.
*
- * @param instream input stream
+ * @param inStream input stream
* @param contentType content type
- * @throws IllegalArgumentException if {@code instream} is {@code null}
+ * @throws IllegalArgumentException if {@code inStream} is {@code null}
* @since 4.3
*/
- public InputStreamEntity(final InputStream instream, final ContentType contentType) {
- this(instream, -1, contentType);
+ public InputStreamEntity(final InputStream inStream, final ContentType contentType) {
+ this(inStream, -1, contentType);
}
/**
- * @param instream input stream
+ * @param inStream input stream
* @param length of the input stream, {@code -1} if unknown
* @param contentType for specifying the {@code Content-Type} header, may be {@code null}
- * @throws IllegalArgumentException if {@code instream} is {@code null}
+ * @throws IllegalArgumentException if {@code inStream} is {@code null}
* @since 4.2
*/
- public InputStreamEntity(final InputStream instream, final long length, final ContentType contentType) {
+ public InputStreamEntity(final InputStream inStream, final long length, final ContentType contentType) {
super();
- this.content = Args.notNull(instream, "Source input stream");
+ this.content = Args.notNull(inStream, "Source input stream");
this.length = length;
if (contentType != null) {
setContentType(contentType.toString());
@@ -122,31 +122,31 @@ public class InputStreamEntity extends AbstractHttpEntity {
*
*/
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = this.content;
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final InputStream inStream = this.content;
try {
final byte[] buffer = new byte[OUTPUT_BUFFER_SIZE];
- int l;
+ int readLen;
if (this.length < 0) {
// consume until EOF
- while ((l = instream.read(buffer)) != -1) {
- outstream.write(buffer, 0, l);
+ while ((readLen = inStream.read(buffer)) != -1) {
+ outStream.write(buffer, 0, readLen);
}
} else {
// consume no more than length
long remaining = this.length;
while (remaining > 0) {
- l = instream.read(buffer, 0, (int)Math.min(OUTPUT_BUFFER_SIZE, remaining));
- if (l == -1) {
+ readLen = inStream.read(buffer, 0, (int)Math.min(OUTPUT_BUFFER_SIZE, remaining));
+ if (readLen == -1) {
break;
}
- outstream.write(buffer, 0, l);
- remaining -= l;
+ outStream.write(buffer, 0, readLen);
+ remaining -= readLen;
}
}
} finally {
- instream.close();
+ inStream.close();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/entity/SerializableEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/SerializableEntity.java b/httpcore/src/main/java/org/apache/http/entity/SerializableEntity.java
index 25bb4a5..573df42 100644
--- a/httpcore/src/main/java/org/apache/http/entity/SerializableEntity.java
+++ b/httpcore/src/main/java/org/apache/http/entity/SerializableEntity.java
@@ -114,15 +114,15 @@ public class SerializableEntity extends AbstractHttpEntity {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
if (this.objSer == null) {
- final ObjectOutputStream out = new ObjectOutputStream(outstream);
+ final ObjectOutputStream out = new ObjectOutputStream(outStream);
out.writeObject(this.objRef);
out.flush();
} else {
- outstream.write(this.objSer);
- outstream.flush();
+ outStream.write(this.objSer);
+ outStream.flush();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/entity/StringEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/StringEntity.java b/httpcore/src/main/java/org/apache/http/entity/StringEntity.java
index 0251676..f799839 100644
--- a/httpcore/src/main/java/org/apache/http/entity/StringEntity.java
+++ b/httpcore/src/main/java/org/apache/http/entity/StringEntity.java
@@ -162,10 +162,10 @@ public class StringEntity extends AbstractHttpEntity implements Cloneable {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- outstream.write(this.content);
- outstream.flush();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ outStream.write(this.content);
+ outStream.flush();
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java b/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
index 4176286..165f9a9 100644
--- a/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
+++ b/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
@@ -75,7 +75,7 @@ import org.apache.http.util.NetUtils;
*/
public class BHttpConnectionBase implements HttpInetConnection {
- private final SessionInputBufferImpl inbuffer;
+ private final SessionInputBufferImpl inBuffer;
private final SessionOutputBufferImpl outbuffer;
private final MessageConstraints messageConstraints;
private final HttpConnectionMetricsImpl connMetrics;
@@ -86,7 +86,7 @@ public class BHttpConnectionBase implements HttpInetConnection {
/**
* Creates new instance of BHttpConnectionBase.
*
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
* @param chardecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
@@ -100,7 +100,7 @@ public class BHttpConnectionBase implements HttpInetConnection {
* {@link StrictContentLengthStrategy#INSTANCE} will be used.
*/
protected BHttpConnectionBase(
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
@@ -108,12 +108,12 @@ public class BHttpConnectionBase implements HttpInetConnection {
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy) {
super();
- Args.positive(buffersize, "Buffer size");
+ Args.positive(bufferSize, "Buffer size");
final HttpTransportMetricsImpl inTransportMetrics = new HttpTransportMetricsImpl();
final HttpTransportMetricsImpl outTransportMetrics = new HttpTransportMetricsImpl();
- this.inbuffer = new SessionInputBufferImpl(inTransportMetrics, buffersize, -1,
+ this.inBuffer = new SessionInputBufferImpl(inTransportMetrics, bufferSize, -1,
messageConstraints != null ? messageConstraints : MessageConstraints.DEFAULT, chardecoder);
- this.outbuffer = new SessionOutputBufferImpl(outTransportMetrics, buffersize, fragmentSizeHint,
+ this.outbuffer = new SessionOutputBufferImpl(outTransportMetrics, bufferSize, fragmentSizeHint,
charencoder);
this.messageConstraints = messageConstraints;
this.connMetrics = new HttpConnectionMetricsImpl(inTransportMetrics, outTransportMetrics);
@@ -129,8 +129,8 @@ public class BHttpConnectionBase implements HttpInetConnection {
if (socket == null) {
throw new ConnectionClosedException();
}
- if (!this.inbuffer.isBound()) {
- this.inbuffer.bind(getSocketInputStream(socket));
+ if (!this.inBuffer.isBound()) {
+ this.inBuffer.bind(getSocketInputStream(socket));
}
if (!this.outbuffer.isBound()) {
this.outbuffer.bind(getSocketOutputStream(socket));
@@ -158,12 +158,12 @@ public class BHttpConnectionBase implements HttpInetConnection {
protected void bind(final Socket socket) throws IOException {
Args.notNull(socket, "Socket");
this.socketHolder.set(socket);
- this.inbuffer.bind(null);
+ this.inBuffer.bind(null);
this.outbuffer.bind(null);
}
protected SessionInputBuffer getSessionInputBuffer() {
- return this.inbuffer;
+ return this.inBuffer;
}
protected SessionOutputBuffer getSessionOutputBuffer() {
@@ -202,15 +202,15 @@ public class BHttpConnectionBase implements HttpInetConnection {
protected InputStream createInputStream(
final long len,
- final SessionInputBuffer inbuffer) {
+ final SessionInputBuffer inBuffer) {
if (len == ContentLengthStrategy.CHUNKED) {
- return new ChunkedInputStream(inbuffer, this.messageConstraints);
+ return new ChunkedInputStream(inBuffer, this.messageConstraints);
} else if (len == ContentLengthStrategy.IDENTITY) {
- return new IdentityInputStream(inbuffer);
+ return new IdentityInputStream(inBuffer);
} else if (len == 0L) {
return EmptyInputStream.INSTANCE;
} else {
- return new ContentLengthInputStream(inbuffer, len);
+ return new ContentLengthInputStream(inBuffer, len);
}
}
@@ -218,19 +218,19 @@ public class BHttpConnectionBase implements HttpInetConnection {
final BasicHttpEntity entity = new BasicHttpEntity();
final long len = this.incomingContentStrategy.determineLength(message);
- final InputStream instream = createInputStream(len, this.inbuffer);
+ final InputStream inStream = createInputStream(len, this.inBuffer);
if (len == ContentLengthStrategy.CHUNKED) {
entity.setChunked(true);
entity.setContentLength(-1);
- entity.setContent(instream);
+ entity.setContent(inStream);
} else if (len == ContentLengthStrategy.IDENTITY) {
entity.setChunked(false);
entity.setContentLength(-1);
- entity.setContent(instream);
+ entity.setContent(inStream);
} else {
entity.setChunked(false);
entity.setContentLength(len);
- entity.setContent(instream);
+ entity.setContent(inStream);
}
final Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
@@ -315,7 +315,7 @@ public class BHttpConnectionBase implements HttpInetConnection {
final Socket socket = this.socketHolder.getAndSet(null);
if (socket != null) {
try {
- this.inbuffer.clear();
+ this.inBuffer.clear();
this.outbuffer.flush();
try {
try {
@@ -340,18 +340,18 @@ public class BHttpConnectionBase implements HttpInetConnection {
final int oldtimeout = socket.getSoTimeout();
try {
socket.setSoTimeout(timeout);
- return this.inbuffer.fillBuffer();
+ return this.inBuffer.fillBuffer();
} finally {
socket.setSoTimeout(oldtimeout);
}
}
protected boolean awaitInput(final int timeout) throws IOException {
- if (this.inbuffer.hasBufferedData()) {
+ if (this.inBuffer.hasBufferedData()) {
return true;
}
fillInputBuffer(timeout);
- return this.inbuffer.hasBufferedData();
+ return this.inBuffer.hasBufferedData();
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java b/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
index 374da33..44c614a 100644
--- a/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
+++ b/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
@@ -65,7 +65,7 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
/**
* Creates new instance of DefaultBHttpClientConnection.
*
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
* @param chardecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
@@ -83,7 +83,7 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
* {@link DefaultHttpResponseParserFactory#INSTANCE} will be used.
*/
public DefaultBHttpClientConnection(
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
@@ -92,7 +92,7 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
- super(buffersize, fragmentSizeHint, chardecoder, charencoder,
+ super(bufferSize, fragmentSizeHint, chardecoder, charencoder,
constraints, incomingContentStrategy, outgoingContentStrategy);
this.requestWriter = (requestWriterFactory != null ? requestWriterFactory :
DefaultHttpRequestWriterFactory.INSTANCE).create(getSessionOutputBuffer());
@@ -101,15 +101,15 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
}
public DefaultBHttpClientConnection(
- final int buffersize,
+ final int bufferSize,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints) {
- this(buffersize, buffersize, chardecoder, charencoder, constraints, null, null, null, null);
+ this(bufferSize, bufferSize, chardecoder, charencoder, constraints, null, null, null, null);
}
- public DefaultBHttpClientConnection(final int buffersize) {
- this(buffersize, buffersize, null, null, null, null, null, null, null);
+ public DefaultBHttpClientConnection(final int bufferSize) {
+ this(bufferSize, bufferSize, null, null, null, null, null, null, null);
}
protected void onResponseReceived(final HttpResponse response) {
@@ -152,9 +152,9 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
if (entity == null) {
return;
}
- final OutputStream outstream = prepareOutput(request);
- entity.writeTo(outstream);
- outstream.close();
+ final OutputStream outStream = prepareOutput(request);
+ entity.writeTo(outStream);
+ outStream.close();
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java b/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
index 85b46b7..5e9f65d 100644
--- a/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
+++ b/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
@@ -63,7 +63,7 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
/**
* Creates new instance of DefaultBHttpServerConnection.
*
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
* @param chardecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
@@ -81,7 +81,7 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
* {@link DefaultHttpResponseWriterFactory#INSTANCE} will be used.
*/
public DefaultBHttpServerConnection(
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
@@ -90,7 +90,7 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageParserFactory<HttpRequest> requestParserFactory,
final HttpMessageWriterFactory<HttpResponse> responseWriterFactory) {
- super(buffersize, fragmentSizeHint, chardecoder, charencoder, constraints,
+ super(bufferSize, fragmentSizeHint, chardecoder, charencoder, constraints,
incomingContentStrategy != null ? incomingContentStrategy :
DisallowIdentityContentLengthStrategy.INSTANCE, outgoingContentStrategy);
this.requestParser = (requestParserFactory != null ? requestParserFactory :
@@ -100,15 +100,15 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
}
public DefaultBHttpServerConnection(
- final int buffersize,
+ final int bufferSize,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints) {
- this(buffersize, buffersize, chardecoder, charencoder, constraints, null, null, null, null);
+ this(bufferSize, bufferSize, chardecoder, charencoder, constraints, null, null, null, null);
}
- public DefaultBHttpServerConnection(final int buffersize) {
- this(buffersize, buffersize, null, null, null, null, null, null, null);
+ public DefaultBHttpServerConnection(final int bufferSize) {
+ this(bufferSize, bufferSize, null, null, null, null, null, null, null);
}
protected void onRequestReceived(final HttpRequest request) {
@@ -162,9 +162,9 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
if (entity == null) {
return;
}
- final OutputStream outstream = prepareOutput(response);
- entity.writeTo(outstream);
- outstream.close();
+ final OutputStream outStream = prepareOutput(response);
+ entity.writeTo(outStream);
+ outStream.close();
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java b/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java
index 9dc9c92..72a7878 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/AbstractMessageParser.java
@@ -119,7 +119,7 @@ public abstract class AbstractMessageParser<T extends HttpMessage> implements Ht
* Parses HTTP headers from the data receiver stream according to the generic
* format as given in Section 3.1 of RFC 822, RFC-2616 Section 4 and 19.3.
*
- * @param inbuffer Session input buffer
+ * @param inBuffer Session input buffer
* @param maxHeaderCount maximum number of headers allowed. If the number
* of headers received from the data stream exceeds maxCount value, an
* IOException will be thrown. Setting this parameter to a negative value
@@ -135,12 +135,12 @@ public abstract class AbstractMessageParser<T extends HttpMessage> implements Ht
* @throws HttpException in case of HTTP protocol violation
*/
public static Header[] parseHeaders(
- final SessionInputBuffer inbuffer,
+ final SessionInputBuffer inBuffer,
final int maxHeaderCount,
final int maxLineLen,
final LineParser parser) throws HttpException, IOException {
final List<CharArrayBuffer> headerLines = new ArrayList<CharArrayBuffer>();
- return parseHeaders(inbuffer, maxHeaderCount, maxLineLen,
+ return parseHeaders(inBuffer, maxHeaderCount, maxLineLen,
parser != null ? parser : BasicLineParser.INSTANCE,
headerLines);
}
@@ -149,7 +149,7 @@ public abstract class AbstractMessageParser<T extends HttpMessage> implements Ht
* Parses HTTP headers from the data receiver stream according to the generic
* format as given in Section 3.1 of RFC 822, RFC-2616 Section 4 and 19.3.
*
- * @param inbuffer Session input buffer
+ * @param inBuffer Session input buffer
* @param maxHeaderCount maximum number of headers allowed. If the number
* of headers received from the data stream exceeds maxCount value, an
* IOException will be thrown. Setting this parameter to a negative value
@@ -170,12 +170,12 @@ public abstract class AbstractMessageParser<T extends HttpMessage> implements Ht
* @since 4.1
*/
public static Header[] parseHeaders(
- final SessionInputBuffer inbuffer,
+ final SessionInputBuffer inBuffer,
final int maxHeaderCount,
final int maxLineLen,
final LineParser parser,
final List<CharArrayBuffer> headerLines) throws HttpException, IOException {
- Args.notNull(inbuffer, "Session input buffer");
+ Args.notNull(inBuffer, "Session input buffer");
Args.notNull(parser, "Line parser");
Args.notNull(headerLines, "Header line list");
@@ -187,8 +187,8 @@ public abstract class AbstractMessageParser<T extends HttpMessage> implements Ht
} else {
current.clear();
}
- final int l = inbuffer.readLine(current);
- if (l == -1 || current.length() < 1) {
+ final int readLen = inBuffer.readLine(current);
+ if (readLen == -1 || current.length() < 1) {
break;
}
// Parse the header name and value
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/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 a87708a..f4f62fa 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
@@ -186,19 +186,18 @@ public class ChunkedInputStream extends InputStream {
return -1;
}
}
- final int bytesRead = in.read(b, off, (int) Math.min(len, chunkSize - pos));
- if (bytesRead != -1) {
- pos += bytesRead;
+ final int readLen = in.read(b, off, (int) Math.min(len, chunkSize - pos));
+ if (readLen != -1) {
+ pos += readLen;
if (pos >= chunkSize) {
state = CHUNK_CRLF;
}
- return bytesRead;
- } else {
- eof = true;
- throw new TruncatedChunkException("Truncated chunk "
- + "( expected size: " + chunkSize
- + "; actual size: " + pos + ")");
+ return readLen;
}
+ eof = true;
+ throw new TruncatedChunkException("Truncated chunk "
+ + "( expected size: " + chunkSize
+ + "; actual size: " + pos + ")");
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java b/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
index 716df8d..6bfbacd 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
@@ -173,16 +173,16 @@ public class ContentLengthInputStream extends InputStream {
if (pos + len > contentLength) {
chunk = (int) (contentLength - pos);
}
- final int count = this.in.read(b, off, chunk);
- if (count == -1 && pos < contentLength) {
+ final int readLen = this.in.read(b, off, chunk);
+ if (readLen == -1 && pos < contentLength) {
throw new ConnectionClosedException(
"Premature end of Content-Length delimited message body (expected: "
+ contentLength + "; received: " + pos + ")");
}
- if (count > 0) {
- pos += count;
+ if (readLen > 0) {
+ pos += readLen;
}
- return count;
+ return readLen;
}
@@ -218,12 +218,12 @@ public class ContentLengthInputStream extends InputStream {
// skip and keep track of the bytes actually skipped
long count = 0;
while (remaining > 0) {
- final int l = read(buffer, 0, (int)Math.min(BUFFER_SIZE, remaining));
- if (l == -1) {
+ final int readLen = read(buffer, 0, (int)Math.min(BUFFER_SIZE, remaining));
+ if (readLen == -1) {
break;
}
- count += l;
- remaining -= l;
+ count += readLen;
+ remaining -= readLen;
}
return count;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpRequestParser.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpRequestParser.java b/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpRequestParser.java
index 11ae414..56a1e3f 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpRequestParser.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpRequestParser.java
@@ -126,8 +126,8 @@ public class DefaultHttpRequestParser extends AbstractMessageParser<HttpRequest>
throws IOException, HttpException, ParseException {
this.lineBuf.clear();
- final int i = sessionBuffer.readLine(this.lineBuf);
- if (i == -1) {
+ final int readLen = sessionBuffer.readLine(this.lineBuf);
+ if (readLen == -1) {
throw new ConnectionClosedException("Client closed connection");
}
final ParserCursor cursor = new ParserCursor(0, this.lineBuf.length());
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpResponseParser.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpResponseParser.java b/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpResponseParser.java
index 5467b40..d1a9787 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpResponseParser.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/DefaultHttpResponseParser.java
@@ -126,8 +126,8 @@ public class DefaultHttpResponseParser extends AbstractMessageParser<HttpRespons
throws IOException, HttpException, ParseException {
this.lineBuf.clear();
- final int i = sessionBuffer.readLine(this.lineBuf);
- if (i == -1) {
+ final int readLen = sessionBuffer.readLine(this.lineBuf);
+ if (readLen == -1) {
throw new NoHttpResponseException("The target server failed to respond");
}
//create the status line from the status string
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/impl/io/IdentityInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/IdentityInputStream.java b/httpcore/src/main/java/org/apache/http/impl/io/IdentityInputStream.java
index a5c20e7..b6d3479 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/IdentityInputStream.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/IdentityInputStream.java
@@ -66,9 +66,8 @@ public class IdentityInputStream extends InputStream {
public int available() throws IOException {
if (this.in instanceof BufferInfo) {
return ((BufferInfo) this.in).length();
- } else {
- return 0;
}
+ return 0;
}
@Override
@@ -78,20 +77,12 @@ public class IdentityInputStream extends InputStream {
@Override
public int read() throws IOException {
- if (this.closed) {
- return -1;
- } else {
- return this.in.read();
- }
+ return this.closed ? -1 : this.in.read();
}
@Override
public int read(final byte[] b, final int off, final int len) throws IOException {
- if (this.closed) {
- return -1;
- } else {
- return this.in.read(b, off, len);
- }
+ return this.closed ? -1 : this.in.read(b, off, len);
}
}
[04/12] httpcomponents-core git commit: Use camel-case for ivars and
param names; don't nest with else clauses unnecessarily;
comment intention of empty blocks;
use "readLen" name for local var instead of "i" or other cryptic name to hold
read length of
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/impl/io/SessionInputBufferImpl.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/SessionInputBufferImpl.java b/httpcore/src/main/java/org/apache/http/impl/io/SessionInputBufferImpl.java
index ff0d21a..6993bae 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/SessionInputBufferImpl.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/SessionInputBufferImpl.java
@@ -60,21 +60,21 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
private final HttpTransportMetricsImpl metrics;
private final byte[] buffer;
- private final ByteArrayBuffer linebuffer;
+ private final ByteArrayBuffer lineBuffer;
private final int minChunkLimit;
private final MessageConstraints constraints;
private final CharsetDecoder decoder;
- private InputStream instream;
- private int bufferpos;
- private int bufferlen;
+ private InputStream inStream;
+ private int bufferPos;
+ private int bufferLen;
private CharBuffer cbuf;
/**
* Creates new instance of SessionInputBufferImpl.
*
* @param metrics HTTP transport metrics.
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param minChunkLimit size limit below which data chunks should be buffered in memory
* in order to minimize native method invocations on the underlying network socket.
* The optimal value of this parameter can be platform specific and defines a trade-off
@@ -82,39 +82,39 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
* If negative default chunk limited will be used.
* @param constraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
- * @param chardecoder chardecoder to be used for decoding HTTP protocol elements.
+ * @param charDecoder CharDecoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
*/
public SessionInputBufferImpl(
final HttpTransportMetricsImpl metrics,
- final int buffersize,
+ final int bufferSize,
final int minChunkLimit,
final MessageConstraints constraints,
- final CharsetDecoder chardecoder) {
+ final CharsetDecoder charDecoder) {
Args.notNull(metrics, "HTTP transport metrcis");
- Args.positive(buffersize, "Buffer size");
+ Args.positive(bufferSize, "Buffer size");
this.metrics = metrics;
- this.buffer = new byte[buffersize];
- this.bufferpos = 0;
- this.bufferlen = 0;
+ this.buffer = new byte[bufferSize];
+ this.bufferPos = 0;
+ this.bufferLen = 0;
this.minChunkLimit = minChunkLimit >= 0 ? minChunkLimit : 512;
this.constraints = constraints != null ? constraints : MessageConstraints.DEFAULT;
- this.linebuffer = new ByteArrayBuffer(buffersize);
- this.decoder = chardecoder;
+ this.lineBuffer = new ByteArrayBuffer(bufferSize);
+ this.decoder = charDecoder;
}
public SessionInputBufferImpl(
final HttpTransportMetricsImpl metrics,
- final int buffersize) {
- this(metrics, buffersize, buffersize, null, null);
+ final int bufferSize) {
+ this(metrics, bufferSize, bufferSize, null, null);
}
- public void bind(final InputStream instream) {
- this.instream = instream;
+ public void bind(final InputStream inputStream) {
+ this.inStream = inputStream;
}
public boolean isBound() {
- return this.instream != null;
+ return this.inStream != null;
}
@Override
@@ -124,7 +124,7 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
@Override
public int length() {
- return this.bufferlen - this.bufferpos;
+ return this.bufferLen - this.bufferPos;
}
@Override
@@ -133,40 +133,39 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
}
private int streamRead(final byte[] b, final int off, final int len) throws IOException {
- Asserts.notNull(this.instream, "Input stream");
- return this.instream.read(b, off, len);
+ Asserts.notNull(this.inStream, "Input stream");
+ return this.inStream.read(b, off, len);
}
public int fillBuffer() throws IOException {
// compact the buffer if necessary
- if (this.bufferpos > 0) {
- final int len = this.bufferlen - this.bufferpos;
+ if (this.bufferPos > 0) {
+ final int len = this.bufferLen - this.bufferPos;
if (len > 0) {
- System.arraycopy(this.buffer, this.bufferpos, this.buffer, 0, len);
+ System.arraycopy(this.buffer, this.bufferPos, this.buffer, 0, len);
}
- this.bufferpos = 0;
- this.bufferlen = len;
+ this.bufferPos = 0;
+ this.bufferLen = len;
}
- final int l;
- final int off = this.bufferlen;
+ final int readLen;
+ final int off = this.bufferLen;
final int len = this.buffer.length - off;
- l = streamRead(this.buffer, off, len);
- if (l == -1) {
+ readLen = streamRead(this.buffer, off, len);
+ if (readLen == -1) {
return -1;
- } else {
- this.bufferlen = off + l;
- this.metrics.incrementBytesTransferred(l);
- return l;
}
+ this.bufferLen = off + readLen;
+ this.metrics.incrementBytesTransferred(readLen);
+ return readLen;
}
public boolean hasBufferedData() {
- return this.bufferpos < this.bufferlen;
+ return this.bufferPos < this.bufferLen;
}
public void clear() {
- this.bufferpos = 0;
- this.bufferlen = 0;
+ this.bufferPos = 0;
+ this.bufferLen = 0;
}
@Override
@@ -178,7 +177,7 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
return -1;
}
}
- return this.buffer[this.bufferpos++] & 0xff;
+ return this.buffer[this.bufferPos++] & 0xff;
}
@Override
@@ -187,32 +186,31 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
return 0;
}
if (hasBufferedData()) {
- final int chunk = Math.min(len, this.bufferlen - this.bufferpos);
- System.arraycopy(this.buffer, this.bufferpos, b, off, chunk);
- this.bufferpos += chunk;
+ final int chunk = Math.min(len, this.bufferLen - this.bufferPos);
+ System.arraycopy(this.buffer, this.bufferPos, b, off, chunk);
+ this.bufferPos += chunk;
return chunk;
}
// If the remaining capacity is big enough, read directly from the
// underlying input stream bypassing the buffer.
if (len > this.minChunkLimit) {
- final int read = streamRead(b, off, len);
- if (read > 0) {
- this.metrics.incrementBytesTransferred(read);
+ final int readLen = streamRead(b, off, len);
+ if (readLen > 0) {
+ this.metrics.incrementBytesTransferred(readLen);
}
- return read;
- } else {
- // otherwise read to the buffer first
- while (!hasBufferedData()) {
- final int noRead = fillBuffer();
- if (noRead == -1) {
- return -1;
- }
+ return readLen;
+ }
+ // otherwise read to the buffer first
+ while (!hasBufferedData()) {
+ final int noRead = fillBuffer();
+ if (noRead == -1) {
+ return -1;
}
- final int chunk = Math.min(len, this.bufferlen - this.bufferpos);
- System.arraycopy(this.buffer, this.bufferpos, b, off, chunk);
- this.bufferpos += chunk;
- return chunk;
}
+ final int chunk = Math.min(len, this.bufferLen - this.bufferPos);
+ System.arraycopy(this.buffer, this.bufferPos, b, off, chunk);
+ this.bufferPos += chunk;
+ return chunk;
}
@Override
@@ -247,7 +245,7 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
while (retry) {
// attempt to find end of line (LF)
int pos = -1;
- for (int i = this.bufferpos; i < this.bufferlen; i++) {
+ for (int i = this.bufferPos; i < this.bufferLen; i++) {
if (this.buffer[i] == HTTP.LF) {
pos = i;
break;
@@ -255,8 +253,8 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
}
if (maxLineLen > 0) {
- final int currentLen = this.linebuffer.length()
- + (pos >= 0 ? pos : this.bufferlen) - this.bufferpos;
+ final int currentLen = this.lineBuffer.length()
+ + (pos >= 0 ? pos : this.bufferLen) - this.bufferPos;
if (currentLen >= maxLineLen) {
throw new MessageConstraintException("Maximum line length limit exceeded");
}
@@ -264,20 +262,20 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
if (pos != -1) {
// end of line found.
- if (this.linebuffer.isEmpty()) {
+ if (this.lineBuffer.isEmpty()) {
// the entire line is preset in the read buffer
return lineFromReadBuffer(charbuffer, pos);
}
retry = false;
- final int len = pos + 1 - this.bufferpos;
- this.linebuffer.append(this.buffer, this.bufferpos, len);
- this.bufferpos = pos + 1;
+ final int len = pos + 1 - this.bufferPos;
+ this.lineBuffer.append(this.buffer, this.bufferPos, len);
+ this.bufferPos = pos + 1;
} else {
// end of line not found
if (hasBufferedData()) {
- final int len = this.bufferlen - this.bufferpos;
- this.linebuffer.append(this.buffer, this.bufferpos, len);
- this.bufferpos = this.bufferlen;
+ final int len = this.bufferLen - this.bufferPos;
+ this.lineBuffer.append(this.buffer, this.bufferPos, len);
+ this.bufferPos = this.bufferLen;
}
noRead = fillBuffer();
if (noRead == -1) {
@@ -285,7 +283,7 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
}
}
}
- if (noRead == -1 && this.linebuffer.isEmpty()) {
+ if (noRead == -1 && this.lineBuffer.isEmpty()) {
// indicate the end of stream
return -1;
}
@@ -308,34 +306,34 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
private int lineFromLineBuffer(final CharArrayBuffer charbuffer)
throws IOException {
// discard LF if found
- int len = this.linebuffer.length();
+ int len = this.lineBuffer.length();
if (len > 0) {
- if (this.linebuffer.byteAt(len - 1) == HTTP.LF) {
+ if (this.lineBuffer.byteAt(len - 1) == HTTP.LF) {
len--;
}
// discard CR if found
if (len > 0) {
- if (this.linebuffer.byteAt(len - 1) == HTTP.CR) {
+ if (this.lineBuffer.byteAt(len - 1) == HTTP.CR) {
len--;
}
}
}
if (this.decoder == null) {
- charbuffer.append(this.linebuffer, 0, len);
+ charbuffer.append(this.lineBuffer, 0, len);
} else {
- final ByteBuffer bbuf = ByteBuffer.wrap(this.linebuffer.buffer(), 0, len);
+ final ByteBuffer bbuf = ByteBuffer.wrap(this.lineBuffer.buffer(), 0, len);
len = appendDecoded(charbuffer, bbuf);
}
- this.linebuffer.clear();
+ this.lineBuffer.clear();
return len;
}
private int lineFromReadBuffer(final CharArrayBuffer charbuffer, final int position)
throws IOException {
int pos = position;
- final int off = this.bufferpos;
+ final int off = this.bufferPos;
int len;
- this.bufferpos = pos + 1;
+ this.bufferPos = pos + 1;
if (pos > off && this.buffer[pos - 1] == HTTP.CR) {
// skip CR if found
pos--;
@@ -389,12 +387,8 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
@Override
public String readLine() throws IOException {
final CharArrayBuffer charbuffer = new CharArrayBuffer(64);
- final int l = readLine(charbuffer);
- if (l != -1) {
- return charbuffer.toString();
- } else {
- return null;
- }
+ final int readLen = readLine(charbuffer);
+ return readLen != -1 ? charbuffer.toString() : null;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java b/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java
index 3ed5206..19175bc 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java
@@ -62,14 +62,14 @@ public class SessionOutputBufferImpl implements SessionOutputBuffer, BufferInfo
private final int fragementSizeHint;
private final CharsetEncoder encoder;
- private OutputStream outstream;
+ private OutputStream outStream;
private ByteBuffer bbuf;
/**
* Creates new instance of SessionOutputBufferImpl.
*
* @param metrics HTTP transport metrics.
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param fragementSizeHint fragment size hint defining a minimal size of a fragment
* that should be written out directly to the socket bypassing the session buffer.
* Value {@code 0} disables fragment buffering.
@@ -78,30 +78,30 @@ public class SessionOutputBufferImpl implements SessionOutputBuffer, BufferInfo
*/
public SessionOutputBufferImpl(
final HttpTransportMetricsImpl metrics,
- final int buffersize,
+ final int bufferSize,
final int fragementSizeHint,
final CharsetEncoder charencoder) {
super();
- Args.positive(buffersize, "Buffer size");
+ Args.positive(bufferSize, "Buffer size");
Args.notNull(metrics, "HTTP transport metrcis");
this.metrics = metrics;
- this.buffer = new ByteArrayBuffer(buffersize);
+ this.buffer = new ByteArrayBuffer(bufferSize);
this.fragementSizeHint = fragementSizeHint >= 0 ? fragementSizeHint : 0;
this.encoder = charencoder;
}
public SessionOutputBufferImpl(
final HttpTransportMetricsImpl metrics,
- final int buffersize) {
- this(metrics, buffersize, buffersize, null);
+ final int bufferSize) {
+ this(metrics, bufferSize, bufferSize, null);
}
- public void bind(final OutputStream outstream) {
- this.outstream = outstream;
+ public void bind(final OutputStream outStream) {
+ this.outStream = outStream;
}
public boolean isBound() {
- return this.outstream != null;
+ return this.outStream != null;
}
@Override
@@ -120,13 +120,13 @@ public class SessionOutputBufferImpl implements SessionOutputBuffer, BufferInfo
}
private void streamWrite(final byte[] b, final int off, final int len) throws IOException {
- Asserts.notNull(outstream, "Output stream");
- this.outstream.write(b, off, len);
+ Asserts.notNull(outStream, "Output stream");
+ this.outStream.write(b, off, len);
}
private void flushStream() throws IOException {
- if (this.outstream != null) {
- this.outstream.flush();
+ if (this.outStream != null) {
+ this.outStream.flush();
}
}
@@ -188,7 +188,7 @@ public class SessionOutputBufferImpl implements SessionOutputBuffer, BufferInfo
this.buffer.append(b);
} else {
flushBuffer();
- this.outstream.write(b);
+ this.outStream.write(b);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java b/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
index fc759f1..289737d 100644
--- a/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
+++ b/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
@@ -250,11 +250,11 @@ public class SSLContextBuilder {
final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException {
Args.notNull(file, "Truststore file");
final KeyStore trustStore = KeyStore.getInstance(keyStoreType);
- final FileInputStream instream = new FileInputStream(file);
+ final FileInputStream inStream = new FileInputStream(file);
try {
- trustStore.load(instream, storePassword);
+ trustStore.load(inStream, storePassword);
} finally {
- instream.close();
+ inStream.close();
}
return loadTrustMaterial(trustStore, trustStrategy);
}
@@ -276,11 +276,11 @@ public class SSLContextBuilder {
final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException {
Args.notNull(url, "Truststore URL");
final KeyStore trustStore = KeyStore.getInstance(keyStoreType);
- final InputStream instream = url.openStream();
+ final InputStream inStream = url.openStream();
try {
- trustStore.load(instream, storePassword);
+ trustStore.load(inStream, storePassword);
} finally {
- instream.close();
+ inStream.close();
}
return loadTrustMaterial(trustStore, trustStrategy);
}
@@ -330,11 +330,11 @@ public class SSLContextBuilder {
final PrivateKeyStrategy aliasStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, CertificateException, IOException {
Args.notNull(file, "Keystore file");
final KeyStore identityStore = KeyStore.getInstance(keyStoreType);
- final FileInputStream instream = new FileInputStream(file);
+ final FileInputStream inStream = new FileInputStream(file);
try {
- identityStore.load(instream, storePassword);
+ identityStore.load(inStream, storePassword);
} finally {
- instream.close();
+ inStream.close();
}
return loadKeyMaterial(identityStore, keyPassword, aliasStrategy);
}
@@ -353,11 +353,11 @@ public class SSLContextBuilder {
final PrivateKeyStrategy aliasStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, CertificateException, IOException {
Args.notNull(url, "Keystore URL");
final KeyStore identityStore = KeyStore.getInstance(keyStoreType);
- final InputStream instream = url.openStream();
+ final InputStream inStream = url.openStream();
try {
- identityStore.load(instream, storePassword);
+ identityStore.load(inStream, storePassword);
} finally {
- instream.close();
+ inStream.close();
}
return loadKeyMaterial(identityStore, keyPassword, aliasStrategy);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/util/EntityUtils.java b/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
index ac795b2..54e946c 100644
--- a/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
+++ b/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
@@ -85,9 +85,9 @@ public final class EntityUtils {
return;
}
if (entity.isStreaming()) {
- final InputStream instream = entity.getContent();
- if (instream != null) {
- instream.close();
+ final InputStream inStream = entity.getContent();
+ if (inStream != null) {
+ inStream.close();
}
}
}
@@ -121,8 +121,8 @@ public final class EntityUtils {
*/
public static byte[] toByteArray(final HttpEntity entity) throws IOException {
Args.notNull(entity, "Entity");
- final InputStream instream = entity.getContent();
- if (instream == null) {
+ final InputStream inStream = entity.getContent();
+ if (inStream == null) {
return null;
}
try {
@@ -135,12 +135,12 @@ public final class EntityUtils {
final ByteArrayBuffer buffer = new ByteArrayBuffer(capacity);
final byte[] tmp = new byte[DEFAULT_BUFFER_SIZE];
int l;
- while((l = instream.read(tmp)) != -1) {
+ while((l = inStream.read(tmp)) != -1) {
buffer.append(tmp, 0, l);
}
return buffer.toByteArray();
} finally {
- instream.close();
+ inStream.close();
}
}
@@ -198,8 +198,8 @@ public final class EntityUtils {
private static String toString(
final HttpEntity entity,
final ContentType contentType) throws IOException {
- final InputStream instream = entity.getContent();
- if (instream == null) {
+ final InputStream inStream = entity.getContent();
+ if (inStream == null) {
return null;
}
try {
@@ -220,7 +220,7 @@ public final class EntityUtils {
if (charset == null) {
charset = HTTP.DEF_CONTENT_CHARSET;
}
- final Reader reader = new InputStreamReader(instream, charset);
+ final Reader reader = new InputStreamReader(inStream, charset);
final CharArrayBuffer buffer = new CharArrayBuffer(capacity);
final char[] tmp = new char[1024];
int l;
@@ -229,7 +229,7 @@ public final class EntityUtils {
}
return buffer.toString();
} finally {
- instream.close();
+ inStream.close();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/TestHttpHost.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/TestHttpHost.java b/httpcore/src/test/java/org/apache/http/TestHttpHost.java
index 674d9e3..280d4f6 100644
--- a/httpcore/src/test/java/org/apache/http/TestHttpHost.java
+++ b/httpcore/src/test/java/org/apache/http/TestHttpHost.java
@@ -187,13 +187,13 @@ public class TestHttpHost {
public void testSerialization() throws Exception {
final HttpHost orig = new HttpHost("somehost", 8080, "https");
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final HttpHost clone = (HttpHost) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final HttpHost clone = (HttpHost) inStream.readObject();
Assert.assertEquals(orig, clone);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/TestHttpVersion.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/TestHttpVersion.java b/httpcore/src/test/java/org/apache/http/TestHttpVersion.java
index 121cbca..a35cbb0 100644
--- a/httpcore/src/test/java/org/apache/http/TestHttpVersion.java
+++ b/httpcore/src/test/java/org/apache/http/TestHttpVersion.java
@@ -116,13 +116,13 @@ public class TestHttpVersion {
public void testSerialization() throws Exception {
final HttpVersion orig = HttpVersion.HTTP_1_1;
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final HttpVersion clone = (HttpVersion) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final HttpVersion clone = (HttpVersion) inStream.readObject();
Assert.assertEquals(orig, clone);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/entity/TestEntityTemplate.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/entity/TestEntityTemplate.java b/httpcore/src/test/java/org/apache/http/entity/TestEntityTemplate.java
index 21d410a..68eee39 100644
--- a/httpcore/src/test/java/org/apache/http/entity/TestEntityTemplate.java
+++ b/httpcore/src/test/java/org/apache/http/entity/TestEntityTemplate.java
@@ -48,8 +48,8 @@ public class TestEntityTemplate {
final HttpEntity httpentity = new EntityTemplate(new ContentProducer() {
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- outstream.write('a');
+ public void writeTo(final OutputStream outStream) throws IOException {
+ outStream.write('a');
}
});
@@ -74,8 +74,8 @@ public class TestEntityTemplate {
final HttpEntity httpentity = new EntityTemplate(new ContentProducer() {
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- outstream.write('a');
+ public void writeTo(final OutputStream outStream) throws IOException {
+ outStream.write('a');
}
});
@@ -99,13 +99,13 @@ public class TestEntityTemplate {
final HttpEntity httpentity = new EntityTemplate(new ContentProducer() {
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- outstream.write('a');
+ public void writeTo(final OutputStream outStream) throws IOException {
+ outStream.write('a');
}
});
- final InputStream instream = httpentity.getContent();
- Assert.assertNotNull(instream);
+ final InputStream inStream = httpentity.getContent();
+ Assert.assertNotNull(inStream);
final String s = EntityUtils.toString(httpentity);
Assert.assertEquals("a", s);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/entity/TestFileEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/entity/TestFileEntity.java b/httpcore/src/test/java/org/apache/http/entity/TestFileEntity.java
index a44789c..880f0b4 100644
--- a/httpcore/src/test/java/org/apache/http/entity/TestFileEntity.java
+++ b/httpcore/src/test/java/org/apache/http/entity/TestFileEntity.java
@@ -94,12 +94,12 @@ public class TestFileEntity {
final File tmpfile = File.createTempFile("testfile", ".txt");
tmpfile.deleteOnExit();
- final FileOutputStream outstream = new FileOutputStream(tmpfile);
- outstream.write(0);
- outstream.write(1);
- outstream.write(2);
- outstream.write(3);
- outstream.close();
+ final FileOutputStream outStream = new FileOutputStream(tmpfile);
+ outStream.write(0);
+ outStream.write(1);
+ outStream.write(2);
+ outStream.write(3);
+ outStream.close();
final FileEntity httpentity = new FileEntity(tmpfile, ContentType.TEXT_PLAIN);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/entity/TestInputStreamEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/entity/TestInputStreamEntity.java b/httpcore/src/test/java/org/apache/http/entity/TestInputStreamEntity.java
index 594edb5..fe00bc7 100644
--- a/httpcore/src/test/java/org/apache/http/entity/TestInputStreamEntity.java
+++ b/httpcore/src/test/java/org/apache/http/entity/TestInputStreamEntity.java
@@ -44,11 +44,11 @@ public class TestInputStreamEntity {
@Test
public void testBasics() throws Exception {
final byte[] bytes = "Message content".getBytes(Consts.ISO_8859_1);
- final InputStream instream = new ByteArrayInputStream(bytes);
- final InputStreamEntity httpentity = new InputStreamEntity(instream, bytes.length);
+ final InputStream inStream = new ByteArrayInputStream(bytes);
+ final InputStreamEntity httpentity = new InputStreamEntity(inStream, bytes.length);
Assert.assertEquals(bytes.length, httpentity.getContentLength());
- Assert.assertEquals(instream, httpentity.getContent());
+ Assert.assertEquals(inStream, httpentity.getContent());
Assert.assertNotNull(httpentity.getContent());
Assert.assertFalse(httpentity.isRepeatable());
Assert.assertTrue(httpentity.isStreaming());
@@ -61,8 +61,8 @@ public class TestInputStreamEntity {
@Test
public void testUnknownLengthConstructor() throws Exception {
- final InputStream instream = new ByteArrayInputStream(new byte[0]);
- final InputStreamEntity httpentity = new InputStreamEntity(instream);
+ final InputStream inStream = new ByteArrayInputStream(new byte[0]);
+ final InputStreamEntity httpentity = new InputStreamEntity(inStream);
Assert.assertEquals(-1, httpentity.getContentLength());
}
@@ -70,8 +70,8 @@ public class TestInputStreamEntity {
public void testWriteTo() throws Exception {
final String message = "Message content";
final byte[] bytes = message.getBytes(Consts.ISO_8859_1);
- final InputStream instream = new ByteArrayInputStream(bytes);
- final InputStreamEntity httpentity = new InputStreamEntity(instream, bytes.length);
+ final InputStream inStream = new ByteArrayInputStream(bytes);
+ final InputStreamEntity httpentity = new InputStreamEntity(inStream, bytes.length);
final ByteArrayOutputStream out = new ByteArrayOutputStream();
httpentity.writeTo(out);
@@ -87,9 +87,9 @@ public class TestInputStreamEntity {
public void testWriteToPartialContent() throws Exception {
final String message = "Message content";
final byte[] bytes = message.getBytes(Consts.ISO_8859_1);
- final InputStream instream = new ByteArrayInputStream(bytes);
+ final InputStream inStream = new ByteArrayInputStream(bytes);
final int contentLength = 7;
- final InputStreamEntity httpentity = new InputStreamEntity(instream, contentLength);
+ final InputStreamEntity httpentity = new InputStreamEntity(inStream, contentLength);
final ByteArrayOutputStream out = new ByteArrayOutputStream();
httpentity.writeTo(out);
@@ -105,8 +105,8 @@ public class TestInputStreamEntity {
public void testWriteToUnknownLength() throws Exception {
final String message = "Message content";
final byte[] bytes = message.getBytes(Consts.ISO_8859_1);
- final InputStream instream = new ByteArrayInputStream(bytes);
- final InputStreamEntity httpentity = new InputStreamEntity(instream);
+ final InputStream inStream = new ByteArrayInputStream(bytes);
+ final InputStreamEntity httpentity = new InputStreamEntity(inStream);
final ByteArrayOutputStream out = new ByteArrayOutputStream();
httpentity.writeTo(out);
@@ -120,8 +120,8 @@ public class TestInputStreamEntity {
@Test(expected = IllegalArgumentException.class)
public void testWriteToNull() throws Exception {
- final InputStream instream = new ByteArrayInputStream(new byte[0]);
- final InputStreamEntity httpentity = new InputStreamEntity(instream, 0);
+ final InputStream inStream = new ByteArrayInputStream(new byte[0]);
+ final InputStreamEntity httpentity = new InputStreamEntity(inStream, 0);
httpentity.writeTo(null);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/impl/SessionInputBufferMock.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/SessionInputBufferMock.java b/httpcore/src/test/java/org/apache/http/impl/SessionInputBufferMock.java
index 79c8f22..5526ed8 100644
--- a/httpcore/src/test/java/org/apache/http/impl/SessionInputBufferMock.java
+++ b/httpcore/src/test/java/org/apache/http/impl/SessionInputBufferMock.java
@@ -45,39 +45,39 @@ public class SessionInputBufferMock extends SessionInputBufferImpl {
public static final int BUFFER_SIZE = 16;
public SessionInputBufferMock(
- final InputStream instream,
- final int buffersize,
+ final InputStream inStream,
+ final int bufferSize,
final MessageConstraints constrains,
final CharsetDecoder decoder) {
- super(new HttpTransportMetricsImpl(), buffersize, -1, constrains, decoder);
- bind(instream);
+ super(new HttpTransportMetricsImpl(), bufferSize, -1, constrains, decoder);
+ bind(inStream);
}
public SessionInputBufferMock(
- final InputStream instream,
- final int buffersize) {
- this(instream, buffersize, null, null);
+ final InputStream inStream,
+ final int bufferSize) {
+ this(inStream, bufferSize, null, null);
}
public SessionInputBufferMock(
final byte[] bytes,
- final int buffersize,
+ final int bufferSize,
final MessageConstraints constrains,
final CharsetDecoder decoder) {
- this(new ByteArrayInputStream(bytes), buffersize, constrains, decoder);
+ this(new ByteArrayInputStream(bytes), bufferSize, constrains, decoder);
}
public SessionInputBufferMock(
final byte[] bytes,
- final int buffersize,
+ final int bufferSize,
final MessageConstraints constrains) {
- this(new ByteArrayInputStream(bytes), buffersize, constrains, null);
+ this(new ByteArrayInputStream(bytes), bufferSize, constrains, null);
}
public SessionInputBufferMock(
final byte[] bytes,
- final int buffersize) {
- this(new ByteArrayInputStream(bytes), buffersize);
+ final int bufferSize) {
+ this(new ByteArrayInputStream(bytes), bufferSize);
}
public SessionInputBufferMock(
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/impl/SessionOutputBufferMock.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/SessionOutputBufferMock.java b/httpcore/src/test/java/org/apache/http/impl/SessionOutputBufferMock.java
index 9354c25..421d849 100644
--- a/httpcore/src/test/java/org/apache/http/impl/SessionOutputBufferMock.java
+++ b/httpcore/src/test/java/org/apache/http/impl/SessionOutputBufferMock.java
@@ -46,18 +46,18 @@ public class SessionOutputBufferMock extends SessionOutputBufferImpl {
public SessionOutputBufferMock(
final ByteArrayOutputStream buffer,
- final int buffersize,
+ final int bufferSize,
final int fragementSizeHint,
final CharsetEncoder encoder) {
- super(new HttpTransportMetricsImpl(), buffersize, fragementSizeHint, encoder);
+ super(new HttpTransportMetricsImpl(), bufferSize, fragementSizeHint, encoder);
bind(buffer);
this.buffer = buffer;
}
public SessionOutputBufferMock(
final ByteArrayOutputStream buffer,
- final int buffersize) {
- this(buffer, buffersize, buffersize, null);
+ final int bufferSize) {
+ this(buffer, bufferSize, bufferSize, null);
}
public SessionOutputBufferMock(
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java b/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java
index f966181..111200c 100644
--- a/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java
+++ b/httpcore/src/test/java/org/apache/http/impl/TestBHttpConnectionBase.java
@@ -110,11 +110,11 @@ public class TestBHttpConnectionBase {
@Test
public void testConnectionClose() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
- final OutputStream outstream = Mockito.mock(OutputStream.class);
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ final OutputStream outStream = Mockito.mock(OutputStream.class);
- Mockito.when(socket.getInputStream()).thenReturn(instream);
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
conn.ensureOpen();
@@ -126,7 +126,7 @@ public class TestBHttpConnectionBase {
Assert.assertFalse(conn.isOpen());
- Mockito.verify(outstream, Mockito.times(1)).write(
+ Mockito.verify(outStream, Mockito.times(1)).write(
Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt());
Mockito.verify(socket, Mockito.times(1)).shutdownInput();
Mockito.verify(socket, Mockito.times(1)).shutdownOutput();
@@ -134,16 +134,16 @@ public class TestBHttpConnectionBase {
conn.close();
Mockito.verify(socket, Mockito.times(1)).close();
- Mockito.verify(outstream, Mockito.times(1)).write(
+ Mockito.verify(outStream, Mockito.times(1)).write(
Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt());
}
@Test
public void testConnectionShutdown() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
- final OutputStream outstream = Mockito.mock(OutputStream.class);
- Mockito.when(socket.getInputStream()).thenReturn(instream);
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ final OutputStream outStream = Mockito.mock(OutputStream.class);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
conn.ensureOpen();
@@ -155,7 +155,7 @@ public class TestBHttpConnectionBase {
Assert.assertFalse(conn.isOpen());
- Mockito.verify(outstream, Mockito.never()).write(
+ Mockito.verify(outStream, Mockito.never()).write(
Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt());
Mockito.verify(socket, Mockito.never()).shutdownInput();
Mockito.verify(socket, Mockito.never()).shutdownOutput();
@@ -184,9 +184,9 @@ public class TestBHttpConnectionBase {
final Header ce = entity.getContentEncoding();
Assert.assertNotNull(ce);
Assert.assertEquals("identity", ce.getValue());
- final InputStream instream = entity.getContent();
- Assert.assertNotNull(instream);
- Assert.assertTrue((instream instanceof ContentLengthInputStream));
+ final InputStream inStream = entity.getContent();
+ Assert.assertNotNull(inStream);
+ Assert.assertTrue((inStream instanceof ContentLengthInputStream));
}
@Test
@@ -197,9 +197,9 @@ public class TestBHttpConnectionBase {
Assert.assertNotNull(entity);
Assert.assertTrue(entity.isChunked());
Assert.assertEquals(-1, entity.getContentLength());
- final InputStream instream = entity.getContent();
- Assert.assertNotNull(instream);
- Assert.assertTrue((instream instanceof ChunkedInputStream));
+ final InputStream inStream = entity.getContent();
+ Assert.assertNotNull(inStream);
+ Assert.assertTrue((inStream instanceof ChunkedInputStream));
}
@Test
@@ -209,35 +209,35 @@ public class TestBHttpConnectionBase {
Assert.assertNotNull(entity);
Assert.assertFalse(entity.isChunked());
Assert.assertEquals(-1, entity.getContentLength());
- final InputStream instream = entity.getContent();
- Assert.assertNotNull(instream);
- Assert.assertTrue((instream instanceof IdentityInputStream));
+ final InputStream inStream = entity.getContent();
+ Assert.assertNotNull(inStream);
+ Assert.assertTrue((inStream instanceof IdentityInputStream));
}
@Test
public void testPrepareOutputLengthDelimited() throws Exception {
final HttpResponse message = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
message.addHeader("Content-Length", "10");
- final OutputStream outstream = conn.prepareOutput(message);
- Assert.assertNotNull(outstream);
- Assert.assertTrue((outstream instanceof ContentLengthOutputStream));
+ final OutputStream outStream = conn.prepareOutput(message);
+ Assert.assertNotNull(outStream);
+ Assert.assertTrue((outStream instanceof ContentLengthOutputStream));
}
@Test
public void testPrepareOutputChunked() throws Exception {
final HttpResponse message = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
message.addHeader("Transfer-Encoding", "chunked");
- final OutputStream outstream = conn.prepareOutput(message);
- Assert.assertNotNull(outstream);
- Assert.assertTrue((outstream instanceof ChunkedOutputStream));
+ final OutputStream outStream = conn.prepareOutput(message);
+ Assert.assertNotNull(outStream);
+ Assert.assertTrue((outStream instanceof ChunkedOutputStream));
}
@Test
public void testPrepareOutputIdentity() throws Exception {
final HttpResponse message = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
- final OutputStream outstream = conn.prepareOutput(message);
- Assert.assertNotNull(outstream);
- Assert.assertTrue((outstream instanceof IdentityOutputStream));
+ final OutputStream outStream = conn.prepareOutput(message);
+ Assert.assertNotNull(outStream);
+ Assert.assertTrue((outStream instanceof IdentityOutputStream));
}
@Test
@@ -282,9 +282,9 @@ public class TestBHttpConnectionBase {
@Test
public void testAwaitInputInBuffer() throws Exception {
- final ByteArrayInputStream instream = Mockito.spy(new ByteArrayInputStream(
+ final ByteArrayInputStream inStream = Mockito.spy(new ByteArrayInputStream(
new byte[] {1, 2, 3, 4, 5}));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
conn.ensureOpen();
@@ -293,15 +293,15 @@ public class TestBHttpConnectionBase {
Assert.assertTrue(conn.awaitInput(432));
Mockito.verify(socket, Mockito.never()).setSoTimeout(Matchers.anyInt());
- Mockito.verify(instream, Mockito.times(1)).read(
+ Mockito.verify(inStream, Mockito.times(1)).read(
Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt());
}
@Test
public void testAwaitInputInSocket() throws Exception {
- final ByteArrayInputStream instream = Mockito.spy(new ByteArrayInputStream(
+ final ByteArrayInputStream inStream = Mockito.spy(new ByteArrayInputStream(
new byte[] {1, 2, 3, 4, 5}));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
Mockito.when(socket.getSoTimeout()).thenReturn(345);
conn.bind(socket);
@@ -311,15 +311,15 @@ public class TestBHttpConnectionBase {
Mockito.verify(socket, Mockito.times(1)).setSoTimeout(432);
Mockito.verify(socket, Mockito.times(1)).setSoTimeout(345);
- Mockito.verify(instream, Mockito.times(1)).read(
+ Mockito.verify(inStream, Mockito.times(1)).read(
Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt());
}
@Test
public void testAwaitInputNoData() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
- Mockito.when(socket.getInputStream()).thenReturn(instream);
- Mockito.when(instream.read(Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt()))
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
+ Mockito.when(inStream.read(Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt()))
.thenReturn(-1);
conn.bind(socket);
@@ -338,9 +338,9 @@ public class TestBHttpConnectionBase {
@Test
public void testNotStaleWhenHasData() throws Exception {
- final ByteArrayInputStream instream = Mockito.spy(new ByteArrayInputStream(
+ final ByteArrayInputStream inStream = Mockito.spy(new ByteArrayInputStream(
new byte[] {1, 2, 3, 4, 5}));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
conn.ensureOpen();
@@ -350,9 +350,9 @@ public class TestBHttpConnectionBase {
@Test
public void testStaleWhenEndOfStream() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
- Mockito.when(socket.getInputStream()).thenReturn(instream);
- Mockito.when(instream.read(Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt()))
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
+ Mockito.when(inStream.read(Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt()))
.thenReturn(-1);
conn.bind(socket);
@@ -363,9 +363,9 @@ public class TestBHttpConnectionBase {
@Test
public void testNotStaleWhenTimeout() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
- Mockito.when(socket.getInputStream()).thenReturn(instream);
- Mockito.when(instream.read(Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt()))
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
+ Mockito.when(inStream.read(Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt()))
.thenThrow(new SocketTimeoutException());
conn.bind(socket);
@@ -376,9 +376,9 @@ public class TestBHttpConnectionBase {
@Test
public void testStaleWhenIOError() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
- Mockito.when(socket.getInputStream()).thenReturn(instream);
- Mockito.when(instream.read(Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt()))
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
+ Mockito.when(inStream.read(Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt()))
.thenThrow(new SocketException());
conn.bind(socket);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpClientConnection.java b/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpClientConnection.java
index 38cca3c..74bfeee 100644
--- a/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpClientConnection.java
+++ b/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpClientConnection.java
@@ -81,8 +81,8 @@ public class TestDefaultBHttpClientConnection {
@Test
public void testReadRequestHead() throws Exception {
final String s = "HTTP/1.1 200 OK\r\nUser-Agent: test\r\n\r\n";
- final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(Consts.ASCII));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(s.getBytes(Consts.ASCII));
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
@@ -99,8 +99,8 @@ public class TestDefaultBHttpClientConnection {
@Test
public void testReadRequestEntity() throws Exception {
final String s = "HTTP/1.1 200 OK\r\nUser-Agent: test\r\nContent-Length: 3\r\n\r\n123";
- final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(Consts.ASCII));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(s.getBytes(Consts.ASCII));
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
@@ -124,8 +124,8 @@ public class TestDefaultBHttpClientConnection {
@Test
public void testWriteResponseHead() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -138,14 +138,14 @@ public class TestDefaultBHttpClientConnection {
conn.flush();
Assert.assertEquals(1, conn.getMetrics().getRequestCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("GET /stuff HTTP/1.1\r\nUser-Agent: test\r\n\r\n", s);
}
@Test
public void testWriteResponseEntity() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -162,7 +162,7 @@ public class TestDefaultBHttpClientConnection {
conn.flush();
Assert.assertEquals(1, conn.getMetrics().getRequestCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("POST /stuff HTTP/1.1\r\nUser-Agent: test\r\nContent-Length: 3\r\n\r\n123", s);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpServerConnection.java b/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpServerConnection.java
index b59ee8a..749388d 100644
--- a/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpServerConnection.java
+++ b/httpcore/src/test/java/org/apache/http/impl/TestDefaultBHttpServerConnection.java
@@ -80,8 +80,8 @@ public class TestDefaultBHttpServerConnection {
@Test
public void testReadRequestHead() throws Exception {
final String s = "GET / HTTP/1.1\r\nUser-Agent: test\r\n\r\n";
- final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(Consts.ASCII));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(s.getBytes(Consts.ASCII));
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
@@ -99,8 +99,8 @@ public class TestDefaultBHttpServerConnection {
@Test
public void testReadRequestEntity() throws Exception {
final String s = "POST / HTTP/1.1\r\nUser-Agent: test\r\nContent-Length: 3\r\n\r\n123";
- final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes(Consts.ASCII));
- Mockito.when(socket.getInputStream()).thenReturn(instream);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(s.getBytes(Consts.ASCII));
+ Mockito.when(socket.getInputStream()).thenReturn(inStream);
conn.bind(socket);
@@ -126,8 +126,8 @@ public class TestDefaultBHttpServerConnection {
@Test
public void testWriteResponseHead() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -140,14 +140,14 @@ public class TestDefaultBHttpServerConnection {
conn.flush();
Assert.assertEquals(1, conn.getMetrics().getResponseCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("HTTP/1.1 200 OK\r\nUser-Agent: test\r\n\r\n", s);
}
@Test
public void testWriteResponse100Head() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -159,14 +159,14 @@ public class TestDefaultBHttpServerConnection {
conn.flush();
Assert.assertEquals(0, conn.getMetrics().getResponseCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("HTTP/1.1 100 Go on\r\n\r\n", s);
}
@Test
public void testWriteResponseEntity() throws Exception {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- Mockito.when(socket.getOutputStream()).thenReturn(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ Mockito.when(socket.getOutputStream()).thenReturn(outStream);
conn.bind(socket);
@@ -182,7 +182,7 @@ public class TestDefaultBHttpServerConnection {
conn.flush();
Assert.assertEquals(1, conn.getMetrics().getResponseCount());
- final String s = new String(outstream.toByteArray(), "ASCII");
+ final String s = new String(outStream.toByteArray(), "ASCII");
Assert.assertEquals("HTTP/1.1 200 OK\r\nUser-Agent: test\r\nContent-Length: 3\r\n\r\n123", s);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java b/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
index 2454042..5be18e5 100644
--- a/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
+++ b/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
@@ -116,8 +116,8 @@ public class TestContentLengthInputStream {
@Test
public void testClose() throws IOException {
final String correct = "1234567890123456-";
- final SessionInputBuffer inbuffer = new SessionInputBufferMock(correct, Consts.ISO_8859_1);
- final InputStream in = new ContentLengthInputStream(inbuffer, 16L);
+ final SessionInputBuffer inBuffer = new SessionInputBufferMock(correct, Consts.ISO_8859_1);
+ final InputStream in = new ContentLengthInputStream(inBuffer, 16L);
in.close();
in.close();
try {
@@ -139,14 +139,14 @@ public class TestContentLengthInputStream {
} catch (final IOException ex) {
// expected
}
- Assert.assertEquals('-', inbuffer.read());
+ Assert.assertEquals('-', inBuffer.read());
}
@Test
public void testTruncatedContent() throws IOException {
final String correct = "1234567890123456";
- final SessionInputBuffer inbuffer = new SessionInputBufferMock(correct, Consts.ISO_8859_1);
- final InputStream in = new ContentLengthInputStream(inbuffer, 32L);
+ final SessionInputBuffer inBuffer = new SessionInputBufferMock(correct, Consts.ISO_8859_1);
+ final InputStream in = new ContentLengthInputStream(inBuffer, 32L);
final byte[] tmp = new byte[32];
final int byteRead = in.read(tmp);
Assert.assertEquals(16, byteRead);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityInputStream.java b/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityInputStream.java
index 59a46b5..ba64604 100644
--- a/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityInputStream.java
+++ b/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityInputStream.java
@@ -55,44 +55,44 @@ public class TestIdentityInputStream {
public void testBasicRead() throws Exception {
final byte[] input = new byte[] {'a', 'b', 'c'};
final SessionInputBufferMock receiver = new SessionInputBufferMock(input);
- final IdentityInputStream instream = new IdentityInputStream(receiver);
+ final IdentityInputStream inStream = new IdentityInputStream(receiver);
final byte[] tmp = new byte[2];
- Assert.assertEquals(2, instream.read(tmp, 0, tmp.length));
+ Assert.assertEquals(2, inStream.read(tmp, 0, tmp.length));
Assert.assertEquals('a', tmp[0]);
Assert.assertEquals('b', tmp[1]);
- Assert.assertEquals('c', instream.read());
- Assert.assertEquals(-1, instream.read(tmp, 0, tmp.length));
- Assert.assertEquals(-1, instream.read());
- Assert.assertEquals(-1, instream.read(tmp, 0, tmp.length));
- Assert.assertEquals(-1, instream.read());
- instream.close();
+ Assert.assertEquals('c', inStream.read());
+ Assert.assertEquals(-1, inStream.read(tmp, 0, tmp.length));
+ Assert.assertEquals(-1, inStream.read());
+ Assert.assertEquals(-1, inStream.read(tmp, 0, tmp.length));
+ Assert.assertEquals(-1, inStream.read());
+ inStream.close();
}
@Test
public void testClosedCondition() throws Exception {
final byte[] input = new byte[] {'a', 'b', 'c'};
final SessionInputBufferMock receiver = new SessionInputBufferMock(input);
- final IdentityInputStream instream = new IdentityInputStream(receiver);
+ final IdentityInputStream inStream = new IdentityInputStream(receiver);
- instream.close();
- instream.close();
+ inStream.close();
+ inStream.close();
- Assert.assertEquals(0, instream.available());
+ Assert.assertEquals(0, inStream.available());
final byte[] tmp = new byte[2];
- Assert.assertEquals(-1, instream.read(tmp, 0, tmp.length));
- Assert.assertEquals(-1, instream.read());
- Assert.assertEquals(-1, instream.read(tmp, 0, tmp.length));
- Assert.assertEquals(-1, instream.read());
+ Assert.assertEquals(-1, inStream.read(tmp, 0, tmp.length));
+ Assert.assertEquals(-1, inStream.read());
+ Assert.assertEquals(-1, inStream.read(tmp, 0, tmp.length));
+ Assert.assertEquals(-1, inStream.read());
}
@Test
public void testAvailable() throws Exception {
final byte[] input = new byte[] {'a', 'b', 'c'};
final SessionInputBufferMock receiver = new SessionInputBufferMock(input);
- final IdentityInputStream instream = new IdentityInputStream(receiver);
- instream.read();
- Assert.assertEquals(2, instream.available());
- instream.close();
+ final IdentityInputStream inStream = new IdentityInputStream(receiver);
+ inStream.read();
+ Assert.assertEquals(2, inStream.available());
+ inStream.close();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityOutputStream.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityOutputStream.java b/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityOutputStream.java
index 5b818c2..28ba4a0 100644
--- a/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityOutputStream.java
+++ b/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityOutputStream.java
@@ -101,10 +101,10 @@ public class TestIdentityOutputStream {
@Test
public void testBasicWrite() throws Exception {
final SessionOutputBufferMock transmitter = new SessionOutputBufferMock();
- final IdentityOutputStream outstream = new IdentityOutputStream(transmitter);
- outstream.write(new byte[] {'a', 'b'}, 0, 2);
- outstream.write('c');
- outstream.flush();
+ final IdentityOutputStream outStream = new IdentityOutputStream(transmitter);
+ outStream.write(new byte[] {'a', 'b'}, 0, 2);
+ outStream.write('c');
+ outStream.flush();
final byte[] input = transmitter.getData();
@@ -114,25 +114,25 @@ public class TestIdentityOutputStream {
for (int i = 0; i < expected.length; i++) {
Assert.assertEquals(expected[i], input[i]);
}
- outstream.close();
+ outStream.close();
}
@Test
public void testClosedCondition() throws Exception {
final SessionOutputBufferMock transmitter = new SessionOutputBufferMock();
- final IdentityOutputStream outstream = new IdentityOutputStream(transmitter);
- outstream.close();
- outstream.close();
+ final IdentityOutputStream outStream = new IdentityOutputStream(transmitter);
+ outStream.close();
+ outStream.close();
try {
final byte[] tmp = new byte[2];
- outstream.write(tmp, 0, tmp.length);
+ outStream.write(tmp, 0, tmp.length);
Assert.fail("IOException should have been thrown");
} catch (final IOException e) {
//expected
}
try {
- outstream.write('a');
+ outStream.write('a');
Assert.fail("IOException should have been thrown");
} catch (final IOException e) {
//expected
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java b/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java
index ad6a050..2640903 100644
--- a/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java
+++ b/httpcore/src/test/java/org/apache/http/impl/io/TestRequestParser.java
@@ -57,9 +57,9 @@ public class TestRequestParser {
"User-Agent: whatever\r\n" +
"Cookie: c1=stuff\r\n" +
"\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts.ASCII);
+ final SessionInputBuffer inBuffer = new SessionInputBufferMock(s, Consts.ASCII);
- final DefaultHttpRequestParser parser = new DefaultHttpRequestParser(inbuffer);
+ final DefaultHttpRequestParser parser = new DefaultHttpRequestParser(inBuffer);
final HttpRequest httprequest = parser.parse();
final RequestLine reqline = httprequest.getRequestLine();
@@ -73,9 +73,9 @@ public class TestRequestParser {
@Test
public void testConnectionClosedException() throws Exception {
- final SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {});
+ final SessionInputBuffer inBuffer = new SessionInputBufferMock(new byte[] {});
- final DefaultHttpRequestParser parser = new DefaultHttpRequestParser(inbuffer);
+ final DefaultHttpRequestParser parser = new DefaultHttpRequestParser(inBuffer);
try {
parser.parse();
Assert.fail("ConnectionClosedException should have been thrown");
@@ -91,10 +91,10 @@ public class TestRequestParser {
"User-Agent: whatever\r\n" +
"Coo\000kie: c1=stuff\r\n" +
"\000\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferMock(
+ final SessionInputBuffer inBuffer = new SessionInputBufferMock(
new TimeoutByteArrayInputStream(s.getBytes(Consts.ASCII)), 16);
- final DefaultHttpRequestParser parser = new DefaultHttpRequestParser(inbuffer);
+ final DefaultHttpRequestParser parser = new DefaultHttpRequestParser(inBuffer);
int timeoutCount = 0;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java b/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java
index 5c5fc93..a927732 100644
--- a/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java
+++ b/httpcore/src/test/java/org/apache/http/impl/io/TestResponseParser.java
@@ -58,9 +58,9 @@ public class TestResponseParser {
"Date: some date\r\n" +
"Set-Cookie: c1=stuff\r\n" +
"\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts.ASCII);
+ final SessionInputBuffer inBuffer = new SessionInputBufferMock(s, Consts.ASCII);
- final DefaultHttpResponseParser parser = new DefaultHttpResponseParser(inbuffer);
+ final DefaultHttpResponseParser parser = new DefaultHttpResponseParser(inBuffer);
final HttpResponse httpresponse = parser.parse();
final StatusLine statusline = httpresponse.getStatusLine();
@@ -74,9 +74,9 @@ public class TestResponseParser {
@Test
public void testConnectionClosedException() throws Exception {
- final SessionInputBuffer inbuffer = new SessionInputBufferMock(new byte[] {});
+ final SessionInputBuffer inBuffer = new SessionInputBufferMock(new byte[] {});
- final DefaultHttpResponseParser parser = new DefaultHttpResponseParser(inbuffer);
+ final DefaultHttpResponseParser parser = new DefaultHttpResponseParser(inBuffer);
try {
parser.parse();
Assert.fail("NoHttpResponseException should have been thrown");
@@ -92,10 +92,10 @@ public class TestResponseParser {
"Date: some date\r\n" +
"Set-Coo\000kie: c1=stuff\r\n" +
"\000\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferMock(
+ final SessionInputBuffer inBuffer = new SessionInputBufferMock(
new TimeoutByteArrayInputStream(s.getBytes(Consts.ASCII)), 16);
- final DefaultHttpResponseParser parser = new DefaultHttpResponseParser(inbuffer);
+ final DefaultHttpResponseParser parser = new DefaultHttpResponseParser(inBuffer);
int timeoutCount = 0;
[11/12] httpcomponents-core git commit: [HTTPCORE-550] When a
ParseException is caught and rethrown as an IOException in
org.apache.http.impl.nio.codecs.ChunkDecoder.processFooters(),
the IOException does not chain the original ParseException.
Posted by ol...@apache.org.
[HTTPCORE-550] When a ParseException is caught and rethrown as an
IOException in org.apache.http.impl.nio.codecs.ChunkDecoder.processFooters(),
the IOException does not chain the original ParseException.
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/14e3a19a
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/14e3a19a
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/14e3a19a
Branch: refs/heads/4.4.x
Commit: 14e3a19a9b2f3983b05f6f9600293fd036eaa4a3
Parents: 9bfbbb4
Author: Gary Gregory <ga...@gmail.com>
Authored: Mon Aug 13 22:04:01 2018 -0600
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue Aug 14 09:49:35 2018 +0200
----------------------------------------------------------------------
RELEASE_NOTES.txt | 3 +++
.../main/java/org/apache/http/impl/nio/codecs/ChunkDecoder.java | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/14e3a19a/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 6ebc2db..f6d6b14 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -11,6 +11,9 @@ Changelog
* Fix typos in exception messages.
Contributed by Gary Gregory <ggregory at apache.org>
+
+* HTTPCORE-550: When a ParseException is caught and rethrown as an IOException in org.apache.http.impl.nio.codecs.ChunkDecoder.processFooters(), the IOException does not chain the original ParseException.
+ Contributed by Gary Gregory <ggregory at apache.org>
Release 4.4.10
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/14e3a19a/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 77e05dd..6cd8adb 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
@@ -174,7 +174,7 @@ public class ChunkDecoder extends AbstractContentDecoder {
try {
this.footers[i] = new BufferedHeader(this.trailerBufs.get(i));
} catch (final ParseException ex) {
- throw new IOException(ex.getMessage());
+ throw new IOException(ex);
}
}
}
[02/12] httpcomponents-core git commit: Javadoc. Do not nest in else
clauses unnecessarily. Don't hide ivars.
Posted by ol...@apache.org.
Javadoc. Do not nest in else clauses unnecessarily. Don't hide ivars.
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/4592ae67
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/4592ae67
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/4592ae67
Branch: refs/heads/4.4.x
Commit: 4592ae67295000a674fc2461e3c5af2dee096cec
Parents: 5e7de73
Author: Gary Gregory <ga...@gmail.com>
Authored: Mon Aug 13 19:48:19 2018 -0600
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue Aug 14 09:49:35 2018 +0200
----------------------------------------------------------------------
.../org/apache/http/nio/FileContentDecoder.java | 5 +--
.../http/impl/AbstractHttpClientConnection.java | 32 ++++++++++++--------
.../java/org/apache/http/entity/FileEntity.java | 14 +++++++++
.../apache/http/entity/HttpEntityWrapper.java | 4 ++-
.../apache/http/entity/SerializableEntity.java | 16 +++++-----
5 files changed, 48 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/4592ae67/httpcore-nio/src/main/java/org/apache/http/nio/FileContentDecoder.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/FileContentDecoder.java b/httpcore-nio/src/main/java/org/apache/http/nio/FileContentDecoder.java
index 51014dd..6e543b0 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/FileContentDecoder.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/FileContentDecoder.java
@@ -39,11 +39,12 @@ public interface FileContentDecoder extends ContentDecoder {
/**
* Transfers a portion of entity content from the underlying network channel
- * into the given file channel.<br>
- *
+ * into the given file channel.
+ * <p>
* <b>Warning</b>: Many implementations cannot write beyond the length of the file.
* If the position exceeds the channel's size, some implementations
* may throw an IOException.
+ * </p>
*
* @param dst the target FileChannel to transfer data into.
* @param position
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/4592ae67/httpcore/src/main/java-deprecated/org/apache/http/impl/AbstractHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java-deprecated/org/apache/http/impl/AbstractHttpClientConnection.java b/httpcore/src/main/java-deprecated/org/apache/http/impl/AbstractHttpClientConnection.java
index 6f2b816..d8e02f8 100644
--- a/httpcore/src/main/java-deprecated/org/apache/http/impl/AbstractHttpClientConnection.java
+++ b/httpcore/src/main/java-deprecated/org/apache/http/impl/AbstractHttpClientConnection.java
@@ -61,6 +61,7 @@ import org.apache.http.util.Args;
* <p>
* The following parameters can be used to customize the behavior of this
* class:
+ * </p>
* <ul>
* <li>{@link org.apache.http.params.CoreProtocolPNames#STRICT_TRANSFER_ENCODING}</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_HEADER_COUNT}</li>
@@ -91,6 +92,7 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
* and {@link #createEntitySerializer()} methods in order to initialize
* HTTP entity serializer and deserializer implementations for this
* connection.
+ * </p>
*/
public AbstractHttpClientConnection() {
super();
@@ -113,6 +115,7 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
* This method can be overridden in a super class in order to create
* instances of {@link EntityDeserializer} using a custom
* {@link org.apache.http.entity.ContentLengthStrategy}.
+ * </p>
*
* @return HTTP entity deserializer
*/
@@ -128,6 +131,7 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
* This method can be overridden in a super class in order to create
* instances of {@link EntitySerializer} using a custom
* {@link org.apache.http.entity.ContentLengthStrategy}.
+ * </p>
*
* @return HTTP entity serialzier.
*/
@@ -142,6 +146,7 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
* <p>
* This method can be overridden in a super class in order to provide
* a different implementation of the {@link HttpResponseFactory} interface.
+ * </p>
*
* @return HTTP response factory.
*/
@@ -158,6 +163,7 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
* to pass a different implementation of the
* {@link org.apache.http.message.LineParser} to the the
* {@link DefaultHttpResponseParser} constructor.
+ * </p>
*
* @param buffer the session input buffer.
* @param responseFactory the HTTP response factory.
@@ -180,6 +186,7 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
* to pass a different implementation of
* {@link org.apache.http.message.LineFormatter} to the the default implementation
* {@link HttpRequestWriter}.
+ * </p>
*
* @param buffer the session output buffer
* @param params HTTP parameters
@@ -211,29 +218,30 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
* and {@link #createResponseParser(SessionInputBuffer, HttpResponseFactory, HttpParams)}
* methods to initialize HTTP request writer and response parser for this
* connection.
+ * </p>
*
- * @param inBuffer the session input buffer.
- * @param outbuffer the session output buffer.
+ * @param sessionInputBuffer the session input buffer.
+ * @param sessionOutputBuffer the session output buffer.
* @param params HTTP parameters.
*/
protected void init(
- final SessionInputBuffer inBuffer,
- final SessionOutputBuffer outbuffer,
+ final SessionInputBuffer sessionInputBuffer,
+ final SessionOutputBuffer sessionOutputBuffer,
final HttpParams params) {
- this.inBuffer = Args.notNull(inBuffer, "Input session buffer");
- this.outbuffer = Args.notNull(outbuffer, "Output session buffer");
- if (inBuffer instanceof EofSensor) {
- this.eofSensor = (EofSensor) inBuffer;
+ this.inBuffer = Args.notNull(sessionInputBuffer, "Input session buffer");
+ this.outbuffer = Args.notNull(sessionOutputBuffer, "Output session buffer");
+ if (sessionInputBuffer instanceof EofSensor) {
+ this.eofSensor = (EofSensor) sessionInputBuffer;
}
this.responseParser = createResponseParser(
- inBuffer,
+ sessionInputBuffer,
createHttpResponseFactory(),
params);
this.requestWriter = createRequestWriter(
- outbuffer, params);
+ sessionOutputBuffer, params);
this.metrics = createConnectionMetrics(
- inBuffer.getMetrics(),
- outbuffer.getMetrics());
+ sessionInputBuffer.getMetrics(),
+ sessionOutputBuffer.getMetrics());
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/4592ae67/httpcore/src/main/java/org/apache/http/entity/FileEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/FileEntity.java b/httpcore/src/main/java/org/apache/http/entity/FileEntity.java
index 9ad2210..05448d6 100644
--- a/httpcore/src/main/java/org/apache/http/entity/FileEntity.java
+++ b/httpcore/src/main/java/org/apache/http/entity/FileEntity.java
@@ -45,6 +45,11 @@ public class FileEntity extends AbstractHttpEntity implements Cloneable {
protected final File file;
/**
+ * Creates a new instance.
+ *
+ * @param file The file to serve.
+ * @param contentType The content type for the given {@code file}.
+ *
* @deprecated (4.1.3) {@link #FileEntity(File, ContentType)}
*/
@Deprecated
@@ -55,6 +60,11 @@ public class FileEntity extends AbstractHttpEntity implements Cloneable {
}
/**
+ * Creates a new instance.
+ *
+ * @param file The file to serve.
+ * @param contentType The content type for the given {@code file}.
+ *
* @since 4.2
*/
public FileEntity(final File file, final ContentType contentType) {
@@ -66,6 +76,10 @@ public class FileEntity extends AbstractHttpEntity implements Cloneable {
}
/**
+ * Creates a new instance.
+ *
+ * @param file The file to serve.
+ *
* @since 4.2
*/
public FileEntity(final File file) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/4592ae67/httpcore/src/main/java/org/apache/http/entity/HttpEntityWrapper.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/HttpEntityWrapper.java b/httpcore/src/main/java/org/apache/http/entity/HttpEntityWrapper.java
index 6081cbb..da91352 100644
--- a/httpcore/src/main/java/org/apache/http/entity/HttpEntityWrapper.java
+++ b/httpcore/src/main/java/org/apache/http/entity/HttpEntityWrapper.java
@@ -51,11 +51,13 @@ public class HttpEntityWrapper implements HttpEntity {
/**
* Creates a new entity wrapper.
+ *
+ * @param wrappedEntity the entity to wrap.
*/
public HttpEntityWrapper(final HttpEntity wrappedEntity) {
super();
this.wrappedEntity = Args.notNull(wrappedEntity, "Wrapped entity");
- } // constructor
+ }
@Override
public boolean isRepeatable() {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/4592ae67/httpcore/src/main/java/org/apache/http/entity/SerializableEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/SerializableEntity.java b/httpcore/src/main/java/org/apache/http/entity/SerializableEntity.java
index 573df42..675c008 100644
--- a/httpcore/src/main/java/org/apache/http/entity/SerializableEntity.java
+++ b/httpcore/src/main/java/org/apache/http/entity/SerializableEntity.java
@@ -70,12 +70,16 @@ public class SerializableEntity extends AbstractHttpEntity {
}
/**
+ * Creates new instance of this class.
+ *
+ * @param serializable The object to serialize.
+ *
* @since 4.3
*/
- public SerializableEntity(final Serializable ser) {
+ public SerializableEntity(final Serializable serializable) {
super();
- Args.notNull(ser, "Source object");
- this.objRef = ser;
+ Args.notNull(serializable, "Source object");
+ this.objRef = serializable;
}
private void createBytes(final Serializable ser) throws IOException {
@@ -96,11 +100,7 @@ public class SerializableEntity extends AbstractHttpEntity {
@Override
public long getContentLength() {
- if (this.objSer == null) {
- return -1;
- } else {
- return this.objSer.length;
- }
+ return this.objSer == null ? -1 : this.objSer.length;
}
@Override
[03/12] httpcomponents-core git commit: Use camel-case for ivars and
param names; don't nest with else clauses unnecessarily;
comment intention of empty blocks;
use "readLen" name for local var instead of "i" or other cryptic name to hold
read length of
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java b/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
index b5cff65..680a84c 100644
--- a/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
+++ b/httpcore/src/test/java/org/apache/http/impl/io/TestSessionInOutBuffers.java
@@ -49,13 +49,13 @@ public class TestSessionInOutBuffers {
@Test
public void testBasicBufferProperties() throws Exception {
- final SessionInputBufferMock inbuffer = new SessionInputBufferMock(new byte[] { 1, 2 , 3});
- Assert.assertEquals(SessionInputBufferMock.BUFFER_SIZE, inbuffer.capacity());
- Assert.assertEquals(SessionInputBufferMock.BUFFER_SIZE, inbuffer.available());
- Assert.assertEquals(0, inbuffer.length());
- inbuffer.read();
- Assert.assertEquals(SessionInputBufferMock.BUFFER_SIZE - 2, inbuffer.available());
- Assert.assertEquals(2, inbuffer.length());
+ final SessionInputBufferMock inBuffer = new SessionInputBufferMock(new byte[] { 1, 2 , 3});
+ Assert.assertEquals(SessionInputBufferMock.BUFFER_SIZE, inBuffer.capacity());
+ Assert.assertEquals(SessionInputBufferMock.BUFFER_SIZE, inBuffer.available());
+ Assert.assertEquals(0, inBuffer.length());
+ inBuffer.read();
+ Assert.assertEquals(SessionInputBufferMock.BUFFER_SIZE - 2, inBuffer.available());
+ Assert.assertEquals(2, inBuffer.length());
final SessionOutputBufferMock outbuffer = new SessionOutputBufferMock();
Assert.assertEquals(SessionOutputBufferMock.BUFFER_SIZE, outbuffer.capacity());
@@ -102,16 +102,16 @@ public class TestSessionInOutBuffers {
}
Assert.assertEquals(expected, bytesWritten);
- final SessionInputBufferMock inbuffer = new SessionInputBufferMock(
+ final SessionInputBufferMock inBuffer = new SessionInputBufferMock(
outbuffer.getData());
for (final String teststr : teststrs) {
- Assert.assertEquals(teststr, inbuffer.readLine());
+ Assert.assertEquals(teststr, inBuffer.readLine());
}
- Assert.assertNull(inbuffer.readLine());
- Assert.assertNull(inbuffer.readLine());
- tmetrics = inbuffer.getMetrics();
+ Assert.assertNull(inBuffer.readLine());
+ Assert.assertNull(inBuffer.readLine());
+ tmetrics = inBuffer.getMetrics();
final long bytesRead = tmetrics.getBytesTransferred();
Assert.assertEquals(expected, bytesRead);
}
@@ -170,20 +170,20 @@ public class TestSessionInOutBuffers {
bytesWritten = outbuffer.getMetrics().getBytesTransferred();
Assert.assertEquals(8 + 14 + 2 + 15 + 2 + 16 + 2 + 1, bytesWritten);
- final SessionInputBufferMock inbuffer = new SessionInputBufferMock(
+ final SessionInputBufferMock inBuffer = new SessionInputBufferMock(
outbuffer.getData());
- Assert.assertEquals("a", inbuffer.readLine());
- Assert.assertEquals("", inbuffer.readLine());
- Assert.assertEquals("\r", inbuffer.readLine());
- Assert.assertEquals("", inbuffer.readLine());
- Assert.assertEquals(s1, inbuffer.readLine());
- Assert.assertEquals(s2, inbuffer.readLine());
- Assert.assertEquals(s3, inbuffer.readLine());
- Assert.assertEquals("a", inbuffer.readLine());
- Assert.assertNull(inbuffer.readLine());
- Assert.assertNull(inbuffer.readLine());
- final long bytesRead = inbuffer.getMetrics().getBytesTransferred();
+ Assert.assertEquals("a", inBuffer.readLine());
+ Assert.assertEquals("", inBuffer.readLine());
+ Assert.assertEquals("\r", inBuffer.readLine());
+ Assert.assertEquals("", inBuffer.readLine());
+ Assert.assertEquals(s1, inBuffer.readLine());
+ Assert.assertEquals(s2, inBuffer.readLine());
+ Assert.assertEquals(s3, inBuffer.readLine());
+ Assert.assertEquals("a", inBuffer.readLine());
+ Assert.assertNull(inBuffer.readLine());
+ Assert.assertNull(inBuffer.readLine());
+ final long bytesRead = inBuffer.getMetrics().getBytesTransferred();
Assert.assertEquals(bytesWritten, bytesRead);
}
@@ -222,15 +222,15 @@ public class TestSessionInOutBuffers {
}
Assert.assertEquals(expected, bytesWritten);
- final SessionInputBufferMock inbuffer = new SessionInputBufferMock(
+ final SessionInputBufferMock inBuffer = new SessionInputBufferMock(
outbuffer.getData(), 1024);
for (final String teststr : teststrs) {
- Assert.assertEquals(teststr, inbuffer.readLine());
+ Assert.assertEquals(teststr, inBuffer.readLine());
}
- Assert.assertNull(inbuffer.readLine());
- Assert.assertNull(inbuffer.readLine());
- final long bytesRead = inbuffer.getMetrics().getBytesTransferred();
+ Assert.assertNull(inBuffer.readLine());
+ Assert.assertNull(inBuffer.readLine());
+ final long bytesRead = inBuffer.getMetrics().getBytesTransferred();
Assert.assertEquals(expected, bytesRead);
}
@@ -263,12 +263,12 @@ public class TestSessionInOutBuffers {
Assert.assertEquals(out[i], tmp[i]);
}
- final SessionInputBufferMock inbuffer = new SessionInputBufferMock(tmp);
+ final SessionInputBufferMock inBuffer = new SessionInputBufferMock(tmp);
// these read operations will have no effect
- Assert.assertEquals(0, inbuffer.read(null, 0, 10));
- Assert.assertEquals(0, inbuffer.read(null));
- long bytesRead = inbuffer.getMetrics().getBytesTransferred();
+ Assert.assertEquals(0, inBuffer.read(null, 0, 10));
+ Assert.assertEquals(0, inBuffer.read(null));
+ long bytesRead = inBuffer.getMetrics().getBytesTransferred();
Assert.assertEquals(0, bytesRead);
final byte[] in = new byte[40];
@@ -279,19 +279,19 @@ public class TestSessionInOutBuffers {
if (chunk > remaining) {
chunk = remaining;
}
- final int l = inbuffer.read(in, off, chunk);
- if (l == -1) {
+ final int readLen = inBuffer.read(in, off, chunk);
+ if (readLen == -1) {
break;
}
- off += l;
- remaining -= l;
+ off += readLen;
+ remaining -= readLen;
}
for (int i = 0; i < out.length; i++) {
Assert.assertEquals(out[i], in[i]);
}
- Assert.assertEquals(-1, inbuffer.read(tmp));
- Assert.assertEquals(-1, inbuffer.read(tmp));
- bytesRead = inbuffer.getMetrics().getBytesTransferred();
+ Assert.assertEquals(-1, inBuffer.read(tmp));
+ Assert.assertEquals(-1, inBuffer.read(tmp));
+ bytesRead = inBuffer.getMetrics().getBytesTransferred();
Assert.assertEquals(out.length, bytesRead);
}
@@ -316,45 +316,45 @@ public class TestSessionInOutBuffers {
Assert.assertEquals(out[i], tmp[i]);
}
- final SessionInputBufferMock inbuffer = new SessionInputBufferMock(tmp);
+ final SessionInputBufferMock inBuffer = new SessionInputBufferMock(tmp);
final byte[] in = new byte[40];
for (int i = 0; i < in.length; i++) {
- in[i] = (byte)inbuffer.read();
+ in[i] = (byte)inBuffer.read();
}
for (int i = 0; i < out.length; i++) {
Assert.assertEquals(out[i], in[i]);
}
- Assert.assertEquals(-1, inbuffer.read());
- Assert.assertEquals(-1, inbuffer.read());
- final long bytesRead = inbuffer.getMetrics().getBytesTransferred();
+ Assert.assertEquals(-1, inBuffer.read());
+ Assert.assertEquals(-1, inBuffer.read());
+ final long bytesRead = inBuffer.getMetrics().getBytesTransferred();
Assert.assertEquals(out.length, bytesRead);
}
@Test
public void testWriteSmallFragmentBuffering() throws Exception {
- final ByteArrayOutputStream outstream = Mockito.spy(new ByteArrayOutputStream());
- final SessionOutputBufferMock outbuffer = new SessionOutputBufferMock(outstream, 16, 16, null);
+ final ByteArrayOutputStream outStream = Mockito.spy(new ByteArrayOutputStream());
+ final SessionOutputBufferMock outbuffer = new SessionOutputBufferMock(outStream, 16, 16, null);
outbuffer.write(1);
outbuffer.write(2);
outbuffer.write(new byte[] {1, 2});
outbuffer.write(new byte[]{3, 4});
outbuffer.flush();
- Mockito.verify(outstream, Mockito.times(1)).write(
+ Mockito.verify(outStream, Mockito.times(1)).write(
Matchers.<byte[]>any(), Matchers.anyInt(), Matchers.anyInt());
- Mockito.verify(outstream, Mockito.never()).write(Matchers.anyInt());
+ Mockito.verify(outStream, Mockito.never()).write(Matchers.anyInt());
}
@Test
public void testWriteSmallFragmentNoBuffering() throws Exception {
- final ByteArrayOutputStream outstream = Mockito.spy(new ByteArrayOutputStream());
- final SessionOutputBufferMock outbuffer = new SessionOutputBufferMock(outstream, 16, 0, null);
+ final ByteArrayOutputStream outStream = Mockito.spy(new ByteArrayOutputStream());
+ final SessionOutputBufferMock outbuffer = new SessionOutputBufferMock(outStream, 16, 0, null);
outbuffer.write(1);
outbuffer.write(2);
outbuffer.write(new byte[] {1, 2});
outbuffer.write(new byte[]{3, 4});
- Mockito.verify(outstream, Mockito.times(2)).write(
+ Mockito.verify(outStream, Mockito.times(2)).write(
Matchers.<byte []>any(), Matchers.anyInt(), Matchers.anyInt());
- Mockito.verify(outstream, Mockito.times(2)).write(Matchers.anyInt());
+ Mockito.verify(outStream, Mockito.times(2)).write(Matchers.anyInt());
}
@Test
@@ -362,17 +362,17 @@ public class TestSessionInOutBuffers {
final String s = "a very looooooooooooooooooooooooooooooooooooooooooong line\r\n";
final byte[] tmp = s.getBytes(Consts.ASCII);
// no limit
- final SessionInputBufferMock inbuffer1 = new SessionInputBufferMock(tmp, 5,
+ final SessionInputBufferMock inBuffer1 = new SessionInputBufferMock(tmp, 5,
MessageConstraints.DEFAULT);
- Assert.assertNotNull(inbuffer1.readLine());
- final long bytesRead = inbuffer1.getMetrics().getBytesTransferred();
+ Assert.assertNotNull(inBuffer1.readLine());
+ final long bytesRead = inBuffer1.getMetrics().getBytesTransferred();
Assert.assertEquals(60, bytesRead);
// 15 char limit
- final SessionInputBufferMock inbuffer2 = new SessionInputBufferMock(tmp, 5,
+ final SessionInputBufferMock inBuffer2 = new SessionInputBufferMock(tmp, 5,
MessageConstraints.lineLen(15));
try {
- inbuffer2.readLine();
+ inBuffer2.readLine();
Assert.fail("MessageConstraintException expected");
} catch (final MessageConstraintException ex) {
}
@@ -383,17 +383,17 @@ public class TestSessionInOutBuffers {
final String s = "just a line\r\n";
final byte[] tmp = s.getBytes(Consts.ASCII);
// no limit
- final SessionInputBufferMock inbuffer1 = new SessionInputBufferMock(tmp, 25,
+ final SessionInputBufferMock inBuffer1 = new SessionInputBufferMock(tmp, 25,
MessageConstraints.DEFAULT);
- Assert.assertNotNull(inbuffer1.readLine());
- final long bytesRead = inbuffer1.getMetrics().getBytesTransferred();
+ Assert.assertNotNull(inBuffer1.readLine());
+ final long bytesRead = inBuffer1.getMetrics().getBytesTransferred();
Assert.assertEquals(13, bytesRead);
// 10 char limit
- final SessionInputBufferMock inbuffer2 = new SessionInputBufferMock(tmp, 25,
+ final SessionInputBufferMock inBuffer2 = new SessionInputBufferMock(tmp, 25,
MessageConstraints.lineLen(10));
try {
- inbuffer2.readLine();
+ inBuffer2.readLine();
Assert.fail("MessageConstraintException expected");
} catch (final MessageConstraintException ex) {
}
@@ -403,21 +403,21 @@ public class TestSessionInOutBuffers {
public void testLineLimit3() throws Exception {
final String s = "012345678\r\nblaaaaaaaaaaaaaaaaaah";
final byte[] tmp = s.getBytes(Consts.ASCII);
- final SessionInputBufferMock inbuffer1 = new SessionInputBufferMock(tmp, 10,
+ final SessionInputBufferMock inBuffer1 = new SessionInputBufferMock(tmp, 10,
MessageConstraints.lineLen(20));
- Assert.assertEquals("012345678", inbuffer1.readLine());
+ Assert.assertEquals("012345678", inBuffer1.readLine());
}
@Test
public void testReadLineFringeCase1() throws Exception {
final String s = "abc\r\n";
final byte[] tmp = s.getBytes(Consts.ASCII);
- final SessionInputBufferMock inbuffer1 = new SessionInputBufferMock(tmp, 128);
- Assert.assertEquals('a', inbuffer1.read());
- Assert.assertEquals('b', inbuffer1.read());
- Assert.assertEquals('c', inbuffer1.read());
- Assert.assertEquals('\r', inbuffer1.read());
- Assert.assertEquals("", inbuffer1.readLine());
+ final SessionInputBufferMock inBuffer1 = new SessionInputBufferMock(tmp, 128);
+ Assert.assertEquals('a', inBuffer1.read());
+ Assert.assertEquals('b', inBuffer1.read());
+ Assert.assertEquals('c', inBuffer1.read());
+ Assert.assertEquals('\r', inBuffer1.read());
+ Assert.assertEquals("", inBuffer1.readLine());
}
static final int SWISS_GERMAN_HELLO [] = {
@@ -466,17 +466,17 @@ public class TestSessionInOutBuffers {
(s3.getBytes(Consts.UTF_8).length + 2)) * 10;
Assert.assertEquals(expected, bytesWritten);
- final SessionInputBufferMock inbuffer = new SessionInputBufferMock(
+ final SessionInputBufferMock inBuffer = new SessionInputBufferMock(
outbuffer.getData(), Consts.UTF_8);
for (int i = 0; i < 10; i++) {
- Assert.assertEquals(s1, inbuffer.readLine());
- Assert.assertEquals(s2, inbuffer.readLine());
- Assert.assertEquals(s3, inbuffer.readLine());
+ Assert.assertEquals(s1, inBuffer.readLine());
+ Assert.assertEquals(s2, inBuffer.readLine());
+ Assert.assertEquals(s3, inBuffer.readLine());
}
- Assert.assertNull(inbuffer.readLine());
- Assert.assertNull(inbuffer.readLine());
- final long bytesRead = inbuffer.getMetrics().getBytesTransferred();
+ Assert.assertNull(inBuffer.readLine());
+ Assert.assertNull(inBuffer.readLine());
+ final long bytesRead = inBuffer.getMetrics().getBytesTransferred();
Assert.assertEquals(expected, bytesRead);
}
@@ -498,10 +498,10 @@ public class TestSessionInOutBuffers {
outbuffer.writeLine(chbuffer);
outbuffer.flush();
- final SessionInputBufferMock inbuffer = new SessionInputBufferMock(
+ final SessionInputBufferMock inBuffer = new SessionInputBufferMock(
outbuffer.getData(), Consts.UTF_8);
- Assert.assertEquals(s, inbuffer.readLine());
+ Assert.assertEquals(s, inBuffer.readLine());
}
@Test
@@ -526,21 +526,21 @@ public class TestSessionInOutBuffers {
final long expected = ((s1.toString().getBytes(Consts.ISO_8859_1).length + 2)) * 10 + 2;
Assert.assertEquals(expected, bytesWritten);
- final SessionInputBufferMock inbuffer = new SessionInputBufferMock(
+ final SessionInputBufferMock inBuffer = new SessionInputBufferMock(
outbuffer.getData(), Consts.ISO_8859_1);
final CharArrayBuffer buf = new CharArrayBuffer(64);
for (int i = 0; i < 10; i++) {
buf.clear();
- final int len = inbuffer.readLine(buf);
- Assert.assertEquals(len, SWISS_GERMAN_HELLO.length);
+ final int readLen = inBuffer.readLine(buf);
+ Assert.assertEquals(readLen, SWISS_GERMAN_HELLO.length);
Assert.assertEquals(s1, buf.toString());
}
buf.clear();
- Assert.assertEquals("", inbuffer.readLine());
- Assert.assertNull(inbuffer.readLine());
- Assert.assertNull(inbuffer.readLine());
- final long bytesRead = inbuffer.getMetrics().getBytesTransferred();
+ Assert.assertEquals("", inBuffer.readLine());
+ Assert.assertNull(inBuffer.readLine());
+ Assert.assertNull(inBuffer.readLine());
+ final long bytesRead = inBuffer.getMetrics().getBytesTransferred();
Assert.assertEquals(expected, bytesRead);
}
@@ -586,8 +586,8 @@ public class TestSessionInOutBuffers {
final CharsetDecoder decoder = Consts.UTF_8.newDecoder();
decoder.onMalformedInput(CodingErrorAction.REPORT);
decoder.onUnmappableCharacter(CodingErrorAction.IGNORE);
- final SessionInputBufferMock inbuffer = new SessionInputBufferMock(tmp, decoder);
- inbuffer.readLine();
+ final SessionInputBufferMock inBuffer = new SessionInputBufferMock(tmp, decoder);
+ inBuffer.readLine();
}
@Test
@@ -596,8 +596,8 @@ public class TestSessionInOutBuffers {
final CharsetDecoder decoder = Consts.UTF_8.newDecoder();
decoder.onMalformedInput(CodingErrorAction.REPLACE);
decoder.onUnmappableCharacter(CodingErrorAction.IGNORE);
- final SessionInputBufferMock inbuffer = new SessionInputBufferMock(tmp, decoder);
- final String s = inbuffer.readLine();
+ final SessionInputBufferMock inBuffer = new SessionInputBufferMock(tmp, decoder);
+ final String s = inBuffer.readLine();
Assert.assertEquals("Gr\ufffdezi_z\ufffdm\ufffd", s);
}
@@ -607,20 +607,20 @@ public class TestSessionInOutBuffers {
final CharsetDecoder decoder = Consts.UTF_8.newDecoder();
decoder.onMalformedInput(CodingErrorAction.IGNORE);
decoder.onUnmappableCharacter(CodingErrorAction.IGNORE);
- final SessionInputBufferMock inbuffer = new SessionInputBufferMock(tmp, decoder);
- final String s = inbuffer.readLine();
+ final SessionInputBufferMock inBuffer = new SessionInputBufferMock(tmp, decoder);
+ final String s = inBuffer.readLine();
Assert.assertEquals("Grezi_zm", s);
}
@Test
public void testInvalidCharArrayBuffer() throws Exception {
- final SessionInputBufferMock inbuffer = new SessionInputBufferMock(new byte[] {});
+ final SessionInputBufferMock inBuffer = new SessionInputBufferMock(new byte[] {});
try {
- inbuffer.readLine(null);
+ inBuffer.readLine(null);
Assert.fail("IllegalArgumentException should have been thrown");
} catch (final IllegalArgumentException ex) {
//expected
- final long bytesRead = inbuffer.getMetrics().getBytesTransferred();
+ final long bytesRead = inBuffer.getMetrics().getBytesTransferred();
Assert.assertEquals(0, bytesRead);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java b/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
index fd8934e..2a6aa5b 100644
--- a/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
+++ b/httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
@@ -638,13 +638,13 @@ public class TestSyncHttp {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
+ public void writeTo(final OutputStream outStream) throws IOException {
for (int i = 0; i < this.n; i++) {
- outstream.write(this.raw);
- outstream.write('\r');
- outstream.write('\n');
+ outStream.write(this.raw);
+ outStream.write('\r');
+ outStream.write('\n');
}
- outstream.flush();
+ outStream.flush();
}
}
@@ -735,14 +735,14 @@ public class TestSyncHttp {
final HttpResponse response = this.client.execute(post, host, conn);
final HttpEntity incoming = response.getEntity();
Assert.assertNotNull(incoming);
- final InputStream instream = incoming.getContent();
+ final InputStream inStream = incoming.getContent();
final ContentType contentType = ContentType.getOrDefault(incoming);
Charset charset = contentType.getCharset();
if (charset == null) {
charset = HTTP.DEF_CONTENT_CHARSET;
}
- Assert.assertNotNull(instream);
- final BufferedReader reader = new BufferedReader(new InputStreamReader(instream, charset));
+ Assert.assertNotNull(inStream);
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, charset));
String line;
int count = 0;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/message/TestBufferedHeader.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/message/TestBufferedHeader.java b/httpcore/src/test/java/org/apache/http/message/TestBufferedHeader.java
index ae26655..94f0c76 100644
--- a/httpcore/src/test/java/org/apache/http/message/TestBufferedHeader.java
+++ b/httpcore/src/test/java/org/apache/http/message/TestBufferedHeader.java
@@ -97,13 +97,13 @@ public class TestBufferedHeader {
buf.append("name: value");
final BufferedHeader orig = new BufferedHeader(buf);
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final BufferedHeader clone = (BufferedHeader) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final BufferedHeader clone = (BufferedHeader) inStream.readObject();
Assert.assertEquals(orig.getName(), clone.getName());
Assert.assertEquals(orig.getValue(), clone.getValue());
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/message/TestHeader.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/message/TestHeader.java b/httpcore/src/test/java/org/apache/http/message/TestHeader.java
index 57bf7ea..3760c42 100644
--- a/httpcore/src/test/java/org/apache/http/message/TestHeader.java
+++ b/httpcore/src/test/java/org/apache/http/message/TestHeader.java
@@ -106,13 +106,13 @@ public class TestHeader {
public void testSerialization() throws Exception {
final BasicHeader orig = new BasicHeader("name1", "value1");
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final BasicHeader clone = (BasicHeader) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final BasicHeader clone = (BasicHeader) inStream.readObject();
Assert.assertEquals(orig.getName(), clone.getName());
Assert.assertEquals(orig.getValue(), clone.getValue());
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/message/TestHeaderGroup.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/message/TestHeaderGroup.java b/httpcore/src/test/java/org/apache/http/message/TestHeaderGroup.java
index 6fb6dfb..9899ce6 100644
--- a/httpcore/src/test/java/org/apache/http/message/TestHeaderGroup.java
+++ b/httpcore/src/test/java/org/apache/http/message/TestHeaderGroup.java
@@ -195,13 +195,13 @@ public class TestHeaderGroup {
final Header header3 = new BasicHeader("name", "value3");
orig.setHeaders(new Header[] { header1, header2, header3 });
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final HeaderGroup clone = (HeaderGroup) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final HeaderGroup clone = (HeaderGroup) inStream.readObject();
final Header[] headers1 = orig.getAllHeaders();
final Header[] headers2 = clone.getAllHeaders();
Assert.assertNotNull(headers1);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/message/TestRequestLine.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/message/TestRequestLine.java b/httpcore/src/test/java/org/apache/http/message/TestRequestLine.java
index 8432830..2f04b45 100644
--- a/httpcore/src/test/java/org/apache/http/message/TestRequestLine.java
+++ b/httpcore/src/test/java/org/apache/http/message/TestRequestLine.java
@@ -79,13 +79,13 @@ public class TestRequestLine {
public void testSerialization() throws Exception {
final BasicRequestLine orig = new BasicRequestLine("GET", "/stuff", HttpVersion.HTTP_1_1);
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final BasicRequestLine clone = (BasicRequestLine) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final BasicRequestLine clone = (BasicRequestLine) inStream.readObject();
Assert.assertEquals(orig.getMethod(), clone.getMethod());
Assert.assertEquals(orig.getUri(), clone.getUri());
Assert.assertEquals(orig.getProtocolVersion(), clone.getProtocolVersion());
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/message/TestStatusLine.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/message/TestStatusLine.java b/httpcore/src/test/java/org/apache/http/message/TestStatusLine.java
index d1f7e58..5574ebe 100644
--- a/httpcore/src/test/java/org/apache/http/message/TestStatusLine.java
+++ b/httpcore/src/test/java/org/apache/http/message/TestStatusLine.java
@@ -85,13 +85,13 @@ public class TestStatusLine {
public void testSerialization() throws Exception {
final BasicStatusLine orig = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final BasicStatusLine clone = (BasicStatusLine) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final BasicStatusLine clone = (BasicStatusLine) inStream.readObject();
Assert.assertEquals(orig.getReasonPhrase(), clone.getReasonPhrase());
Assert.assertEquals(orig.getStatusCode(), clone.getStatusCode());
Assert.assertEquals(orig.getProtocolVersion(), clone.getProtocolVersion());
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/protocol/TestHttpService.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/protocol/TestHttpService.java b/httpcore/src/test/java/org/apache/http/protocol/TestHttpService.java
index cd60179..3bcd4bb 100644
--- a/httpcore/src/test/java/org/apache/http/protocol/TestHttpService.java
+++ b/httpcore/src/test/java/org/apache/http/protocol/TestHttpService.java
@@ -169,8 +169,8 @@ public class TestHttpService {
final HttpCoreContext context = HttpCoreContext.create();
final HttpServerConnection conn = Mockito.mock(HttpServerConnection.class);
final HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
- final InputStream instream = Mockito.mock(InputStream.class);
- final InputStreamEntity entity = new InputStreamEntity(instream, -1);
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ final InputStreamEntity entity = new InputStreamEntity(inStream, -1);
request.setEntity(entity);
Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
@@ -188,7 +188,7 @@ public class TestHttpService {
Mockito.verify(conn).receiveRequestEntity(request);
Mockito.verify(httprocessor).process(request, context);
- Mockito.verify(instream).close();
+ Mockito.verify(inStream).close();
Mockito.verify(httprocessor).process(response, context);
Mockito.verify(conn).sendResponseHeader(response);
Mockito.verify(conn).sendResponseEntity(response);
@@ -212,8 +212,8 @@ public class TestHttpService {
final HttpServerConnection conn = Mockito.mock(HttpServerConnection.class);
final HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
request.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
- final InputStream instream = Mockito.mock(InputStream.class);
- final InputStreamEntity entity = new InputStreamEntity(instream, -1);
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ final InputStreamEntity entity = new InputStreamEntity(inStream, -1);
request.setEntity(entity);
Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
@@ -234,7 +234,7 @@ public class TestHttpService {
Mockito.verify(conn).sendResponseHeader(resp100);
Mockito.verify(conn).receiveRequestEntity(request);
Mockito.verify(httprocessor).process(request, context);
- Mockito.verify(instream).close();
+ Mockito.verify(inStream).close();
Mockito.verify(httprocessor).process(response, context);
Mockito.verify(conn).sendResponseHeader(response);
Mockito.verify(conn).sendResponseEntity(response);
@@ -271,8 +271,8 @@ public class TestHttpService {
final HttpServerConnection conn = Mockito.mock(HttpServerConnection.class);
final HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
request.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
- final InputStream instream = Mockito.mock(InputStream.class);
- final InputStreamEntity entity = new InputStreamEntity(instream, -1);
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ final InputStreamEntity entity = new InputStreamEntity(inStream, -1);
request.setEntity(entity);
Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
@@ -315,8 +315,8 @@ public class TestHttpService {
final HttpServerConnection conn = Mockito.mock(HttpServerConnection.class);
final HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
request.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
- final InputStream instream = Mockito.mock(InputStream.class);
- final InputStreamEntity entity = new InputStreamEntity(instream, -1);
+ final InputStream inStream = Mockito.mock(InputStream.class);
+ final InputStreamEntity entity = new InputStreamEntity(inStream, -1);
request.setEntity(entity);
Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java b/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java
index c6bfb83..a623a10 100644
--- a/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java
+++ b/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java
@@ -56,7 +56,7 @@ public class LoggingBHttpClientConnection extends DefaultBHttpClientConnection {
private final Wire wire;
public LoggingBHttpClientConnection(
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
@@ -65,7 +65,7 @@ public class LoggingBHttpClientConnection extends DefaultBHttpClientConnection {
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
- super(buffersize, fragmentSizeHint, chardecoder, charencoder,
+ super(bufferSize, fragmentSizeHint, chardecoder, charencoder,
constraints, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.id = "http-outgoing-" + COUNT.incrementAndGet();
@@ -74,8 +74,8 @@ public class LoggingBHttpClientConnection extends DefaultBHttpClientConnection {
this.wire = new Wire(LogFactory.getLog("org.apache.http.wire"), this.id);
}
- public LoggingBHttpClientConnection(final int buffersize) {
- this(buffersize, buffersize, null, null, null, null, null, null, null);
+ public LoggingBHttpClientConnection(final int bufferSize) {
+ this(bufferSize, bufferSize, null, null, null, null, null, null, null);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java b/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java
index 7ae4050..030a25f 100644
--- a/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java
+++ b/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java
@@ -56,7 +56,7 @@ public class LoggingBHttpServerConnection extends DefaultBHttpServerConnection {
private final Wire wire;
public LoggingBHttpServerConnection(
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
@@ -65,7 +65,7 @@ public class LoggingBHttpServerConnection extends DefaultBHttpServerConnection {
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageParserFactory<HttpRequest> requestParserFactory,
final HttpMessageWriterFactory<HttpResponse> responseWriterFactory) {
- super(buffersize, fragmentSizeHint, chardecoder, charencoder, constraints,
+ super(bufferSize, fragmentSizeHint, chardecoder, charencoder, constraints,
incomingContentStrategy, outgoingContentStrategy,
requestParserFactory, responseWriterFactory);
this.id = "http-incoming-" + COUNT.incrementAndGet();
@@ -74,8 +74,8 @@ public class LoggingBHttpServerConnection extends DefaultBHttpServerConnection {
this.wire = new Wire(LogFactory.getLog("org.apache.http.wire"), this.id);
}
- public LoggingBHttpServerConnection(final int buffersize) {
- this(buffersize, buffersize, null, null, null, null, null, null, null);
+ public LoggingBHttpServerConnection(final int bufferSize) {
+ this(bufferSize, bufferSize, null, null, null, null, null, null, null);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/util/TestByteArrayBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/util/TestByteArrayBuffer.java b/httpcore/src/test/java/org/apache/http/util/TestByteArrayBuffer.java
index 876b218..c0745ee 100644
--- a/httpcore/src/test/java/org/apache/http/util/TestByteArrayBuffer.java
+++ b/httpcore/src/test/java/org/apache/http/util/TestByteArrayBuffer.java
@@ -295,13 +295,13 @@ public class TestByteArrayBuffer {
orig.append(2);
orig.append(3);
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final ByteArrayBuffer clone = (ByteArrayBuffer) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final ByteArrayBuffer clone = (ByteArrayBuffer) inStream.readObject();
Assert.assertEquals(orig.capacity(), clone.capacity());
Assert.assertEquals(orig.length(), clone.length());
final byte[] data = clone.toByteArray();
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore/src/test/java/org/apache/http/util/TestCharArrayBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/util/TestCharArrayBuffer.java b/httpcore/src/test/java/org/apache/http/util/TestCharArrayBuffer.java
index 8dca3b1..19a8d2c 100644
--- a/httpcore/src/test/java/org/apache/http/util/TestCharArrayBuffer.java
+++ b/httpcore/src/test/java/org/apache/http/util/TestCharArrayBuffer.java
@@ -382,13 +382,13 @@ public class TestCharArrayBuffer {
orig.append('b');
orig.append('c');
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final CharArrayBuffer clone = (CharArrayBuffer) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final CharArrayBuffer clone = (CharArrayBuffer) inStream.readObject();
Assert.assertEquals(orig.capacity(), clone.capacity());
Assert.assertEquals(orig.length(), clone.length());
final char[] data = clone.toCharArray();
[08/12] httpcomponents-core git commit: Better exception messages. No
need to break up exception message strings.
Posted by ol...@apache.org.
Better exception messages. No need to break up exception message
strings.
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/ea64b18a
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/ea64b18a
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/ea64b18a
Branch: refs/heads/4.4.x
Commit: ea64b18a3d560b4758759a9290a42edf7d7978c7
Parents: 9dc8fe8
Author: Gary Gregory <ga...@gmail.com>
Authored: Mon Aug 13 17:10:46 2018 -0600
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue Aug 14 09:49:35 2018 +0200
----------------------------------------------------------------------
.../org/apache/http/impl/nio/codecs/ChunkDecoder.java | 10 +++++-----
.../http/impl/nio/codecs/LengthDelimitedDecoder.java | 14 +++++---------
.../org/apache/http/ConnectionClosedException.java | 12 ++++++++++++
.../java/org/apache/http/TruncatedChunkException.java | 12 ++++++++++++
.../org/apache/http/impl/io/ChunkedInputStream.java | 9 ++++-----
.../apache/http/impl/io/ContentLengthInputStream.java | 8 ++++----
.../http/impl/io/ContentLengthOutputStream.java | 4 ++--
7 files changed, 44 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ea64b18a/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..5bc3291 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
@@ -135,8 +135,8 @@ public class ChunkDecoder extends AbstractContentDecoder {
}
this.pos = 0L;
} else if (this.endOfStream) {
- throw new ConnectionClosedException("Premature end of chunk coded message body: " +
- "closing chunk expected");
+ throw new ConnectionClosedException(
+ "Premature end of chunk coded message body: closing chunk expected");
}
}
@@ -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/ea64b18a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
index 64e223a..1493f3d 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
@@ -87,19 +87,15 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
this.completed = true;
if (this.len < this.contentLength) {
throw new ConnectionClosedException(
- "Premature end of Content-Length delimited message body (expected: "
- + this.contentLength + "; received: " + this.len + ")");
+ "Premature end of Content-Length delimited message body (expected: %,d; received: %,d)",
+ contentLength, len);
}
}
this.len += bytesRead;
if (this.len >= this.contentLength) {
this.completed = true;
}
- if (this.completed && bytesRead == 0) {
- return -1;
- } else {
- return bytesRead;
- }
+ return this.completed && bytesRead == 0 ? -1 : bytesRead;
}
@Override
@@ -140,8 +136,8 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
this.completed = true;
if (this.len < this.contentLength) {
throw new ConnectionClosedException(
- "Premature end of Content-Length delimited message body (expected: "
- + this.contentLength + "; received: " + this.len + ")");
+ "Premature end of Content-Length delimited message body (expected: %,d; received: %,d)",
+ contentLength, len);
}
}
this.len += bytesRead;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ea64b18a/httpcore/src/main/java/org/apache/http/ConnectionClosedException.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/ConnectionClosedException.java b/httpcore/src/main/java/org/apache/http/ConnectionClosedException.java
index 0599181..7e406a5 100644
--- a/httpcore/src/main/java/org/apache/http/ConnectionClosedException.java
+++ b/httpcore/src/main/java/org/apache/http/ConnectionClosedException.java
@@ -56,4 +56,16 @@ public class ConnectionClosedException extends IOException {
super(HttpException.clean(message));
}
+ /**
+ * Constructs a new ConnectionClosedException 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...)}.
+ *
+ * @since 4.4.11
+ */
+ public ConnectionClosedException(final String format, final Object... args) {
+ super(HttpException.clean(String.format(format, args)));
+ }
+
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ea64b18a/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..671efb4 100644
--- a/httpcore/src/main/java/org/apache/http/TruncatedChunkException.java
+++ b/httpcore/src/main/java/org/apache/http/TruncatedChunkException.java
@@ -45,4 +45,16 @@ 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...)}.
+ *
+ * @since 4.4.11
+ */
+ 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/ea64b18a/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..68fe740 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);
}
/**
@@ -262,8 +261,8 @@ public class ChunkedInputStream extends InputStream {
this.buffer.clear();
final int bytesRead2 = this.in.readLine(this.buffer);
if (bytesRead2 == -1) {
- throw new ConnectionClosedException("Premature end of chunk coded message body: " +
- "closing chunk expected");
+ throw new ConnectionClosedException(
+ "Premature end of chunk coded message body: closing chunk expected");
}
int separator = this.buffer.indexOf(';');
if (separator < 0) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ea64b18a/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java b/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
index 6bfbacd..c4d8848 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
@@ -138,8 +138,8 @@ public class ContentLengthInputStream extends InputStream {
if (b == -1) {
if (pos < contentLength) {
throw new ConnectionClosedException(
- "Premature end of Content-Length delimited message body (expected: "
- + contentLength + "; received: " + pos + ")");
+ "Premature end of Content-Length delimited message body (expected: %,d; received: %,d)",
+ contentLength, pos);
}
} else {
pos++;
@@ -176,8 +176,8 @@ public class ContentLengthInputStream extends InputStream {
final int readLen = this.in.read(b, off, chunk);
if (readLen == -1 && pos < contentLength) {
throw new ConnectionClosedException(
- "Premature end of Content-Length delimited message body (expected: "
- + contentLength + "; received: " + pos + ")");
+ "Premature end of Content-Length delimited message body (expected: %,d; received: %,d)",
+ contentLength, pos);
}
if (readLen > 0) {
pos += readLen;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ea64b18a/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
[06/12] httpcomponents-core git commit: Use camel-case for ivars and
param names; don't nest with else clauses unnecessarily;
comment intention of empty blocks;
use "readLen" name for local var instead of "i" or other cryptic name to hold
read length of
Posted by ol...@apache.org.
Use camel-case for ivars and param names; don't nest with else clauses
unnecessarily; comment intention of empty blocks; use "readLen" name for
local var instead of "i" or other cryptic name to hold read length of a
read() API call.
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/9dc8fe89
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/9dc8fe89
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/9dc8fe89
Branch: refs/heads/4.4.x
Commit: 9dc8fe899e985731f6790dae5de91a10cb5fd9e8
Parents: 2bfa595
Author: Gary Gregory <ga...@gmail.com>
Authored: Mon Aug 13 15:37:00 2018 -0600
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue Aug 14 09:49:35 2018 +0200
----------------------------------------------------------------------
.../http/benchmark/BenchmarkConnection.java | 4 +-
.../apache/http/benchmark/BenchmarkWorker.java | 6 +-
.../http/benchmark/CountingInputStream.java | 4 +-
.../http/benchmark/CountingOutputStream.java | 4 +-
.../http/nio/entity/BufferingNHttpEntity.java | 10 +-
.../protocol/ThrottlingHttpClientHandler.java | 20 +-
.../protocol/ThrottlingHttpServiceHandler.java | 20 +-
.../impl/nio/DefaultNHttpClientConnection.java | 14 +-
.../impl/nio/DefaultNHttpServerConnection.java | 14 +-
.../http/impl/nio/NHttpConnectionBase.java | 42 ++--
.../nio/reactor/SessionInputBufferImpl.java | 190 ++++++++++--------
.../nio/reactor/SessionOutputBufferImpl.java | 118 +++++++-----
.../nio/entity/EntityAsyncContentProducer.java | 4 +-
.../http/nio/entity/NByteArrayEntity.java | 8 +-
.../org/apache/http/nio/entity/NFileEntity.java | 14 +-
.../apache/http/nio/entity/NStringEntity.java | 8 +-
.../apache/http/nio/util/ExpandableBuffer.java | 16 +-
.../apache/http/nio/util/SharedInputBuffer.java | 19 +-
.../http/nio/util/SharedOutputBuffer.java | 13 +-
.../apache/http/nio/util/SimpleInputBuffer.java | 8 +-
.../http/nio/util/SimpleOutputBuffer.java | 9 +-
.../apache/http/WritableByteChannelMock.java | 4 +-
.../nio/reactor/TestSessionInOutBuffers.java | 52 ++---
.../TestHttpAsyncHandlerCancellable.java | 8 +-
.../integration/TestServerSidePipelining.java | 24 +--
.../org/apache/http/nio/util/TestBuffers.java | 6 +-
.../http/impl/AbstractHttpClientConnection.java | 22 +--
.../http/impl/AbstractHttpServerConnection.java | 20 +-
.../http/impl/SocketHttpClientConnection.java | 18 +-
.../http/impl/SocketHttpServerConnection.java | 18 +-
.../http/impl/entity/EntityDeserializer.java | 18 +-
.../http/impl/entity/EntitySerializer.java | 6 +-
.../impl/io/AbstractSessionInputBuffer.java | 128 ++++++-------
.../impl/io/AbstractSessionOutputBuffer.java | 30 +--
.../apache/http/impl/io/HttpRequestParser.java | 4 +-
.../apache/http/impl/io/HttpResponseParser.java | 4 +-
.../apache/http/impl/io/SocketInputBuffer.java | 6 +-
.../apache/http/impl/io/SocketOutputBuffer.java | 6 +-
.../main/java/org/apache/http/HttpEntity.java | 4 +-
.../org/apache/http/entity/BasicHttpEntity.java | 18 +-
.../apache/http/entity/BufferedHttpEntity.java | 8 +-
.../org/apache/http/entity/ByteArrayEntity.java | 8 +-
.../org/apache/http/entity/ContentProducer.java | 2 +-
.../org/apache/http/entity/EntityTemplate.java | 6 +-
.../java/org/apache/http/entity/FileEntity.java | 14 +-
.../apache/http/entity/HttpEntityWrapper.java | 4 +-
.../apache/http/entity/InputStreamEntity.java | 58 +++---
.../apache/http/entity/SerializableEntity.java | 10 +-
.../org/apache/http/entity/StringEntity.java | 8 +-
.../apache/http/impl/BHttpConnectionBase.java | 44 ++---
.../http/impl/DefaultBHttpClientConnection.java | 20 +-
.../http/impl/DefaultBHttpServerConnection.java | 20 +-
.../http/impl/io/AbstractMessageParser.java | 16 +-
.../apache/http/impl/io/ChunkedInputStream.java | 17 +-
.../http/impl/io/ContentLengthInputStream.java | 18 +-
.../http/impl/io/DefaultHttpRequestParser.java | 4 +-
.../http/impl/io/DefaultHttpResponseParser.java | 4 +-
.../http/impl/io/IdentityInputStream.java | 15 +-
.../http/impl/io/SessionInputBufferImpl.java | 158 ++++++++-------
.../http/impl/io/SessionOutputBufferImpl.java | 30 +--
.../org/apache/http/ssl/SSLContextBuilder.java | 24 +--
.../java/org/apache/http/util/EntityUtils.java | 22 +--
.../test/java/org/apache/http/TestHttpHost.java | 12 +-
.../java/org/apache/http/TestHttpVersion.java | 12 +-
.../apache/http/entity/TestEntityTemplate.java | 16 +-
.../org/apache/http/entity/TestFileEntity.java | 12 +-
.../http/entity/TestInputStreamEntity.java | 26 +--
.../http/impl/SessionInputBufferMock.java | 26 +--
.../http/impl/SessionOutputBufferMock.java | 8 +-
.../http/impl/TestBHttpConnectionBase.java | 98 +++++-----
.../impl/TestDefaultBHttpClientConnection.java | 20 +-
.../impl/TestDefaultBHttpServerConnection.java | 26 +--
.../impl/io/TestContentLengthInputStream.java | 10 +-
.../http/impl/io/TestIdentityInputStream.java | 40 ++--
.../http/impl/io/TestIdentityOutputStream.java | 20 +-
.../apache/http/impl/io/TestRequestParser.java | 12 +-
.../apache/http/impl/io/TestResponseParser.java | 12 +-
.../http/impl/io/TestSessionInOutBuffers.java | 192 +++++++++----------
.../apache/http/integration/TestSyncHttp.java | 16 +-
.../apache/http/message/TestBufferedHeader.java | 12 +-
.../org/apache/http/message/TestHeader.java | 12 +-
.../apache/http/message/TestHeaderGroup.java | 12 +-
.../apache/http/message/TestRequestLine.java | 12 +-
.../org/apache/http/message/TestStatusLine.java | 12 +-
.../apache/http/protocol/TestHttpService.java | 20 +-
.../LoggingBHttpClientConnection.java | 8 +-
.../LoggingBHttpServerConnection.java | 8 +-
.../apache/http/util/TestByteArrayBuffer.java | 12 +-
.../apache/http/util/TestCharArrayBuffer.java | 12 +-
89 files changed, 1073 insertions(+), 1056 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkConnection.java b/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkConnection.java
index 5b695b8..3e99307 100644
--- a/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkConnection.java
+++ b/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkConnection.java
@@ -48,8 +48,8 @@ class BenchmarkConnection extends DefaultBHttpClientConnection {
}
@Override
- protected InputStream createInputStream(final long len, final SessionInputBuffer inbuffer) {
- return new CountingInputStream(super.createInputStream(len, inbuffer), this.stats);
+ protected InputStream createInputStream(final long len, final SessionInputBuffer inBuffer) {
+ return new CountingInputStream(super.createInputStream(len, inBuffer), this.stats);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java
----------------------------------------------------------------------
diff --git a/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java b/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java
index 945021b..d864c8e 100644
--- a/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java
+++ b/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java
@@ -171,16 +171,16 @@ class BenchmarkWorker implements Runnable {
charset = HTTP.DEF_CONTENT_CHARSET;
}
long contentlen = 0;
- final InputStream instream = entity.getContent();
+ final InputStream inStream = entity.getContent();
int l;
- while ((l = instream.read(this.buffer)) != -1) {
+ while ((l = inStream.read(this.buffer)) != -1) {
contentlen += l;
if (config.getVerbosity() >= 4) {
final String s = new String(this.buffer, 0, l, charset);
System.out.print(s);
}
}
- instream.close();
+ inStream.close();
stats.setContentLength(contentlen);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-ab/src/main/java/org/apache/http/benchmark/CountingInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore-ab/src/main/java/org/apache/http/benchmark/CountingInputStream.java b/httpcore-ab/src/main/java/org/apache/http/benchmark/CountingInputStream.java
index a234d92..e834e6d 100644
--- a/httpcore-ab/src/main/java/org/apache/http/benchmark/CountingInputStream.java
+++ b/httpcore-ab/src/main/java/org/apache/http/benchmark/CountingInputStream.java
@@ -34,8 +34,8 @@ class CountingInputStream extends FilterInputStream {
private final Stats stats;
- CountingInputStream(final InputStream instream, final Stats stats) {
- super(instream);
+ CountingInputStream(final InputStream inStream, final Stats stats) {
+ super(inStream);
this.stats = stats;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-ab/src/main/java/org/apache/http/benchmark/CountingOutputStream.java
----------------------------------------------------------------------
diff --git a/httpcore-ab/src/main/java/org/apache/http/benchmark/CountingOutputStream.java b/httpcore-ab/src/main/java/org/apache/http/benchmark/CountingOutputStream.java
index 6544a59..63ced99 100644
--- a/httpcore-ab/src/main/java/org/apache/http/benchmark/CountingOutputStream.java
+++ b/httpcore-ab/src/main/java/org/apache/http/benchmark/CountingOutputStream.java
@@ -34,8 +34,8 @@ class CountingOutputStream extends FilterOutputStream {
private final Stats stats;
- CountingOutputStream(final OutputStream outstream, final Stats stats) {
- super(outstream);
+ CountingOutputStream(final OutputStream outStream, final Stats stats) {
+ super(outStream);
this.stats = stats;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/entity/BufferingNHttpEntity.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/entity/BufferingNHttpEntity.java b/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/entity/BufferingNHttpEntity.java
index f13a8e7..5c7aa9a 100644
--- a/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/entity/BufferingNHttpEntity.java
+++ b/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/entity/BufferingNHttpEntity.java
@@ -109,14 +109,14 @@ public class BufferingNHttpEntity extends HttpEntityWrapper implements
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = getContent();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final InputStream inStream = getContent();
final byte[] buff = new byte[BUFFER_SIZE];
int l;
// consume until EOF
- while ((l = instream.read(buff)) != -1) {
- outstream.write(buff, 0, l);
+ while ((l = inStream.read(buff)) != -1) {
+ outStream.write(buff, 0, l);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java b/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java
index a624b7d..c3689b9 100644
--- a/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java
+++ b/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java
@@ -470,11 +470,11 @@ public class ThrottlingHttpClientHandler extends NHttpHandlerBase
connState.setWorkerRunning(true);
}
- final OutputStream outstream = new ContentOutputStream(
+ final OutputStream outStream = new ContentOutputStream(
connState.getOutbuffer());
- request.getEntity().writeTo(outstream);
- outstream.flush();
- outstream.close();
+ request.getEntity().writeTo(outStream);
+ outStream.flush();
+ outStream.close();
synchronized (connState) {
connState.setWorkerRunning(false);
@@ -580,7 +580,7 @@ public class ThrottlingHttpClientHandler extends NHttpHandlerBase
public static final int RESPONSE_BODY_DONE = 64;
public static final int RESPONSE_DONE = 64;
- private final SharedInputBuffer inbuffer;
+ private final SharedInputBuffer inBuffer;
private final SharedOutputBuffer outbuffer;
private volatile int inputState;
@@ -598,14 +598,14 @@ public class ThrottlingHttpClientHandler extends NHttpHandlerBase
final IOControl ioControl,
final ByteBufferAllocator allocator) {
super();
- this.inbuffer = new SharedInputBuffer(bufsize, ioControl, allocator);
+ this.inBuffer = new SharedInputBuffer(bufsize, ioControl, allocator);
this.outbuffer = new SharedOutputBuffer(bufsize, ioControl, allocator);
this.inputState = READY;
this.outputState = READY;
}
public ContentInputBuffer getInbuffer() {
- return this.inbuffer;
+ return this.inBuffer;
}
public ContentOutputBuffer getOutbuffer() {
@@ -661,21 +661,21 @@ public class ThrottlingHttpClientHandler extends NHttpHandlerBase
}
public void close() {
- this.inbuffer.close();
+ this.inBuffer.close();
this.outbuffer.close();
this.inputState = SHUTDOWN;
this.outputState = SHUTDOWN;
}
public void shutdown() {
- this.inbuffer.shutdown();
+ this.inBuffer.shutdown();
this.outbuffer.shutdown();
this.inputState = SHUTDOWN;
this.outputState = SHUTDOWN;
}
public void resetInput() {
- this.inbuffer.reset();
+ this.inBuffer.reset();
this.request = null;
this.inputState = READY;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java b/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
index 2b9eb64..8624716 100644
--- a/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
+++ b/httpcore-nio/src/main/java-deprecated/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
@@ -587,12 +587,12 @@ public class ThrottlingHttpServiceHandler extends NHttpHandlerBase
if (response.getEntity() != null) {
final ContentOutputBuffer buffer = connState.getOutbuffer();
- final OutputStream outstream = new ContentOutputStream(buffer);
+ final OutputStream outStream = new ContentOutputStream(buffer);
final HttpEntity entity = response.getEntity();
- entity.writeTo(outstream);
- outstream.flush();
- outstream.close();
+ entity.writeTo(outStream);
+ outStream.flush();
+ outStream.close();
}
synchronized (connState) {
@@ -642,7 +642,7 @@ public class ThrottlingHttpServiceHandler extends NHttpHandlerBase
public static final int RESPONSE_BODY_DONE = 32;
public static final int RESPONSE_DONE = 32;
- private final SharedInputBuffer inbuffer;
+ private final SharedInputBuffer inBuffer;
private final SharedOutputBuffer outbuffer;
private volatile int inputState;
@@ -658,14 +658,14 @@ public class ThrottlingHttpServiceHandler extends NHttpHandlerBase
final IOControl ioControl,
final ByteBufferAllocator allocator) {
super();
- this.inbuffer = new SharedInputBuffer(bufsize, ioControl, allocator);
+ this.inBuffer = new SharedInputBuffer(bufsize, ioControl, allocator);
this.outbuffer = new SharedOutputBuffer(bufsize, ioControl, allocator);
this.inputState = READY;
this.outputState = READY;
}
public ContentInputBuffer getInbuffer() {
- return this.inbuffer;
+ return this.inBuffer;
}
public ContentOutputBuffer getOutbuffer() {
@@ -713,21 +713,21 @@ public class ThrottlingHttpServiceHandler extends NHttpHandlerBase
}
public void close() {
- this.inbuffer.close();
+ this.inBuffer.close();
this.outbuffer.close();
this.inputState = SHUTDOWN;
this.outputState = SHUTDOWN;
}
public void shutdown() {
- this.inbuffer.shutdown();
+ this.inBuffer.shutdown();
this.outbuffer.shutdown();
this.inputState = SHUTDOWN;
this.outputState = SHUTDOWN;
}
public void resetInput() {
- this.inbuffer.reset();
+ this.inBuffer.reset();
this.request = null;
this.inputState = READY;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
index d79dff4..4bbab09 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
@@ -105,7 +105,7 @@ public class DefaultNHttpClientConnection
* Creates new instance DefaultNHttpClientConnection given the underlying I/O session.
*
* @param session the underlying I/O session.
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
* @param allocator memory allocator.
* If {@code null} {@link org.apache.http.nio.util.HeapByteBufferAllocator#INSTANCE}
@@ -125,7 +125,7 @@ public class DefaultNHttpClientConnection
*/
public DefaultNHttpClientConnection(
final IOSession session,
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
final ByteBufferAllocator allocator,
final CharsetDecoder chardecoder,
@@ -135,7 +135,7 @@ public class DefaultNHttpClientConnection
final ContentLengthStrategy outgoingContentStrategy,
final NHttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final NHttpMessageParserFactory<HttpResponse> responseParserFactory) {
- super(session, buffersize, fragmentSizeHint, allocator, chardecoder, charencoder,
+ super(session, bufferSize, fragmentSizeHint, allocator, chardecoder, charencoder,
constraints, incomingContentStrategy, outgoingContentStrategy);
this.requestWriter = (requestWriterFactory != null ? requestWriterFactory :
DefaultHttpRequestWriterFactory.INSTANCE).create(this.outbuf);
@@ -148,19 +148,19 @@ public class DefaultNHttpClientConnection
*/
public DefaultNHttpClientConnection(
final IOSession session,
- final int buffersize,
+ final int bufferSize,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints) {
- this(session, buffersize, buffersize, null, chardecoder, charencoder, constraints,
+ this(session, bufferSize, bufferSize, null, chardecoder, charencoder, constraints,
null, null, null, null);
}
/**
* @since 4.3
*/
- public DefaultNHttpClientConnection(final IOSession session, final int buffersize) {
- this(session, buffersize, buffersize, null, null, null, null, null, null, null, null);
+ public DefaultNHttpClientConnection(final IOSession session, final int bufferSize) {
+ this(session, bufferSize, bufferSize, null, null, null, null, null, null, null, null);
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
index 258a321..cef68f1 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
@@ -105,7 +105,7 @@ public class DefaultNHttpServerConnection
* Creates new instance DefaultNHttpServerConnection given the underlying I/O session.
*
* @param session the underlying I/O session.
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
* @param allocator memory allocator.
* If {@code null} {@link org.apache.http.nio.util.HeapByteBufferAllocator#INSTANCE}
@@ -129,7 +129,7 @@ public class DefaultNHttpServerConnection
*/
public DefaultNHttpServerConnection(
final IOSession session,
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
final ByteBufferAllocator allocator,
final CharsetDecoder chardecoder,
@@ -139,7 +139,7 @@ public class DefaultNHttpServerConnection
final ContentLengthStrategy outgoingContentStrategy,
final NHttpMessageParserFactory<HttpRequest> requestParserFactory,
final NHttpMessageWriterFactory<HttpResponse> responseWriterFactory) {
- super(session, buffersize, fragmentSizeHint, allocator, chardecoder, charencoder,
+ super(session, bufferSize, fragmentSizeHint, allocator, chardecoder, charencoder,
constraints,
incomingContentStrategy != null ? incomingContentStrategy :
DisallowIdentityContentLengthStrategy.INSTANCE,
@@ -156,19 +156,19 @@ public class DefaultNHttpServerConnection
*/
public DefaultNHttpServerConnection(
final IOSession session,
- final int buffersize,
+ final int bufferSize,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints) {
- this(session, buffersize, buffersize, null, chardecoder, charencoder, constraints,
+ this(session, bufferSize, bufferSize, null, chardecoder, charencoder, constraints,
null, null, null, null);
}
/**
* @since 4.3
*/
- public DefaultNHttpServerConnection(final IOSession session, final int buffersize) {
- this(session, buffersize, buffersize, null, null, null, null, null, null, null, null);
+ public DefaultNHttpServerConnection(final IOSession session, final int bufferSize) {
+ this(session, bufferSize, bufferSize, null, null, null, null, null, null, null, null);
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
index 0420d9e..a071346 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
@@ -138,13 +138,13 @@ public class NHttpConnectionBase
Args.notNull(session, "I/O session");
Args.notNull(params, "HTTP params");
- int buffersize = params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
- if (buffersize <= 0) {
- buffersize = 4096;
+ int bufferSize = params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
+ if (bufferSize <= 0) {
+ bufferSize = 4096;
}
- int linebuffersize = buffersize;
- if (linebuffersize > 512) {
- linebuffersize = 512;
+ int lineBufferSize = bufferSize;
+ if (lineBufferSize > 512) {
+ lineBufferSize = 512;
}
CharsetDecoder decoder = null;
@@ -162,9 +162,9 @@ public class NHttpConnectionBase
decoder.onMalformedInput(malformedCharAction).onUnmappableCharacter(unmappableCharAction);
encoder.onMalformedInput(malformedCharAction).onUnmappableCharacter(unmappableCharAction);
}
- this.inbuf = new SessionInputBufferImpl(buffersize, linebuffersize, decoder, allocator);
- this.outbuf = new SessionOutputBufferImpl(buffersize, linebuffersize, encoder, allocator);
- this.fragmentSizeHint = buffersize;
+ this.inbuf = new SessionInputBufferImpl(bufferSize, lineBufferSize, decoder, allocator);
+ this.outbuf = new SessionOutputBufferImpl(bufferSize, lineBufferSize, encoder, allocator);
+ this.fragmentSizeHint = bufferSize;
this.constraints = MessageConstraints.DEFAULT;
this.incomingContentStrategy = createIncomingContentStrategy();
@@ -184,7 +184,7 @@ public class NHttpConnectionBase
* Creates new instance NHttpConnectionBase given the underlying I/O session.
*
* @param session the underlying I/O session.
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
* @param allocator memory allocator.
* If {@code null} {@link org.apache.http.nio.util.HeapByteBufferAllocator#INSTANCE}
@@ -204,7 +204,7 @@ public class NHttpConnectionBase
*/
protected NHttpConnectionBase(
final IOSession session,
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
final ByteBufferAllocator allocator,
final CharsetDecoder chardecoder,
@@ -213,14 +213,14 @@ public class NHttpConnectionBase
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy) {
Args.notNull(session, "I/O session");
- Args.positive(buffersize, "Buffer size");
- int linebuffersize = buffersize;
- if (linebuffersize > 512) {
- linebuffersize = 512;
+ Args.positive(bufferSize, "Buffer size");
+ int lineBufferSize = bufferSize;
+ if (lineBufferSize > 512) {
+ lineBufferSize = 512;
}
- this.inbuf = new SessionInputBufferImpl(buffersize, linebuffersize, chardecoder, allocator);
- this.outbuf = new SessionOutputBufferImpl(buffersize, linebuffersize, charencoder, allocator);
- this.fragmentSizeHint = fragmentSizeHint >= 0 ? fragmentSizeHint : buffersize;
+ this.inbuf = new SessionInputBufferImpl(bufferSize, lineBufferSize, chardecoder, allocator);
+ this.outbuf = new SessionOutputBufferImpl(bufferSize, lineBufferSize, charencoder, allocator);
+ this.fragmentSizeHint = fragmentSizeHint >= 0 ? fragmentSizeHint : bufferSize;
this.inTransportMetrics = new HttpTransportMetricsImpl();
this.outTransportMetrics = new HttpTransportMetricsImpl();
@@ -239,7 +239,7 @@ public class NHttpConnectionBase
* Creates new instance NHttpConnectionBase given the underlying I/O session.
*
* @param session the underlying I/O session.
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
* @param allocator memory allocator.
* If {@code null} {@link org.apache.http.nio.util.HeapByteBufferAllocator#INSTANCE}
@@ -257,14 +257,14 @@ public class NHttpConnectionBase
*/
protected NHttpConnectionBase(
final IOSession session,
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
final ByteBufferAllocator allocator,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy) {
- this(session, buffersize, fragmentSizeHint, allocator, chardecoder, charencoder,
+ this(session, bufferSize, fragmentSizeHint, allocator, chardecoder, charencoder,
null, incomingContentStrategy, outgoingContentStrategy);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
index c9984bb..4f9375d 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
@@ -60,19 +60,19 @@ import org.apache.http.util.CharsetUtils;
@SuppressWarnings("deprecation")
public class SessionInputBufferImpl extends ExpandableBuffer implements SessionInputBuffer {
- private final CharsetDecoder chardecoder;
+ private final CharsetDecoder charDecoder;
private final MessageConstraints constraints;
- private final int lineBuffersize;
+ private final int lineBufferSize;
- private CharBuffer charbuffer;
+ private CharBuffer charBuffer;
/**
* Creates SessionInputBufferImpl instance.
*
- * @param buffersize input buffer size
- * @param lineBuffersize buffer size for line operations. Has effect only if
- * {@code chardecoder} is not {@code null}.
- * @param chardecoder chardecoder to be used for decoding HTTP protocol elements.
+ * @param bufferSize input buffer size.
+ * @param lineBufferSize buffer size for line operations. Has effect only if
+ * {@code charDecoder} is not {@code null}.
+ * @param charDecoder CharDecoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
* @param constraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
@@ -82,24 +82,24 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
* @since 4.4
*/
public SessionInputBufferImpl(
- final int buffersize,
- final int lineBuffersize,
+ final int bufferSize,
+ final int lineBufferSize,
final MessageConstraints constraints,
- final CharsetDecoder chardecoder,
+ final CharsetDecoder charDecoder,
final ByteBufferAllocator allocator) {
- super(buffersize, allocator != null ? allocator : HeapByteBufferAllocator.INSTANCE);
- this.lineBuffersize = Args.positive(lineBuffersize, "Line buffer size");
+ super(bufferSize, allocator != null ? allocator : HeapByteBufferAllocator.INSTANCE);
+ this.lineBufferSize = Args.positive(lineBufferSize, "Line buffer size");
this.constraints = constraints != null ? constraints : MessageConstraints.DEFAULT;
- this.chardecoder = chardecoder;
+ this.charDecoder = charDecoder;
}
/**
* Creates SessionInputBufferImpl instance.
*
- * @param buffersize input buffer size
- * @param lineBuffersize buffer size for line operations. Has effect only if
- * {@code chardecoder} is not {@code null}.
- * @param chardecoder chardecoder to be used for decoding HTTP protocol elements.
+ * @param bufferSize input buffer size.
+ * @param lineBufferSize buffer size for line operations. Has effect only if
+ * {@code charDecoder} is not {@code null}.
+ * @param charDecoder CharDecoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
* @param allocator memory allocator.
* If {@code null} {@link HeapByteBufferAllocator#INSTANCE} will be used.
@@ -107,11 +107,11 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
* @since 4.3
*/
public SessionInputBufferImpl(
- final int buffersize,
- final int lineBuffersize,
- final CharsetDecoder chardecoder,
+ final int bufferSize,
+ final int lineBufferSize,
+ final CharsetDecoder charDecoder,
final ByteBufferAllocator allocator) {
- this(buffersize, lineBuffersize, null, chardecoder, allocator);
+ this(bufferSize, lineBufferSize, null, charDecoder, allocator);
}
/**
@@ -121,24 +121,24 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
*/
@Deprecated
public SessionInputBufferImpl(
- final int buffersize,
- final int lineBuffersize,
+ final int bufferSize,
+ final int lineBufferSize,
final ByteBufferAllocator allocator,
final HttpParams params) {
- super(buffersize, allocator);
- this.lineBuffersize = Args.positive(lineBuffersize, "Line buffer size");
+ super(bufferSize, allocator);
+ this.lineBufferSize = Args.positive(lineBufferSize, "Line buffer size");
final String charsetName = (String) params.getParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET);
final Charset charset = CharsetUtils.lookup(charsetName);
if (charset != null) {
- this.chardecoder = charset.newDecoder();
+ this.charDecoder = charset.newDecoder();
final CodingErrorAction a1 = (CodingErrorAction) params.getParameter(
CoreProtocolPNames.HTTP_MALFORMED_INPUT_ACTION);
- this.chardecoder.onMalformedInput(a1 != null ? a1 : CodingErrorAction.REPORT);
+ this.charDecoder.onMalformedInput(a1 != null ? a1 : CodingErrorAction.REPORT);
final CodingErrorAction a2 = (CodingErrorAction) params.getParameter(
CoreProtocolPNames.HTTP_UNMAPPABLE_INPUT_ACTION);
- this.chardecoder.onUnmappableCharacter(a2 != null? a2 : CodingErrorAction.REPORT);
+ this.charDecoder.onUnmappableCharacter(a2 != null? a2 : CodingErrorAction.REPORT);
} else {
- this.chardecoder = null;
+ this.charDecoder = null;
}
this.constraints = MessageConstraints.DEFAULT;
}
@@ -149,49 +149,76 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
*/
@Deprecated
public SessionInputBufferImpl(
- final int buffersize,
- final int linebuffersize,
+ final int bufferSize,
+ final int lineBufferSize,
final HttpParams params) {
- this(buffersize, linebuffersize, HeapByteBufferAllocator.INSTANCE, params);
+ this(bufferSize, lineBufferSize, HeapByteBufferAllocator.INSTANCE, params);
}
/**
+ * Creates SessionInputBufferImpl instance.
+ *
+ * @param bufferSize input buffer size.
+ * @param lineBufferSize buffer size for line operations. Has effect only if
+ * {@code charset} is not {@code null}.
+ * @param charset Charset to be used for decoding HTTP protocol elements.
+ * If {@code null} simple type cast will be used for byte to char conversion.
+ *
* @since 4.3
*/
public SessionInputBufferImpl(
- final int buffersize,
- final int lineBuffersize,
+ final int bufferSize,
+ final int lineBufferSize,
final Charset charset) {
- this(buffersize, lineBuffersize, null,
+ this(bufferSize, lineBufferSize, null,
charset != null ? charset.newDecoder() : null, HeapByteBufferAllocator.INSTANCE);
}
/**
+ * Creates SessionInputBufferImpl instance.
+ *
+ * @param bufferSize input buffer size.
+ * @param lineBufferSize buffer size for line operations. Has effect only if
+ * {@code charset} is not {@code null}.
+ * @param charset Charset to be used for decoding HTTP protocol elements.
+ * If {@code null} simple type cast will be used for byte to char conversion.
+ * @param constraints Message constraints. If {@code null}
+ * {@link MessageConstraints#DEFAULT} will be used.
+ *
* @since 4.3
*/
public SessionInputBufferImpl(
- final int buffersize,
- final int lineBuffersize,
+ final int bufferSize,
+ final int lineBufferSize,
final MessageConstraints constraints,
final Charset charset) {
- this(buffersize, lineBuffersize, constraints,
+ this(bufferSize, lineBufferSize, constraints,
charset != null ? charset.newDecoder() : null, HeapByteBufferAllocator.INSTANCE);
}
/**
+ * Creates SessionInputBufferImpl instance.
+ *
+ * @param bufferSize input buffer size.
+ * @param lineBufferSize buffer size for line operations.
+ *
* @since 4.3
*/
public SessionInputBufferImpl(
- final int buffersize,
- final int lineBuffersize) {
- this(buffersize, lineBuffersize, null, null, HeapByteBufferAllocator.INSTANCE);
+ final int bufferSize,
+ final int lineBufferSize) {
+ this(bufferSize, lineBufferSize, null, null, HeapByteBufferAllocator.INSTANCE);
}
/**
+ * Creates SessionInputBufferImpl instance.
+ *
+ * @param bufferSize input buffer size.
+ *
* @since 4.3
*/
- public SessionInputBufferImpl(final int buffersize) {
- this(buffersize, 256, null, null, HeapByteBufferAllocator.INSTANCE);
+ public SessionInputBufferImpl(final int bufferSize) {
+ this(bufferSize, 256, null, null, HeapByteBufferAllocator.INSTANCE);
}
@Override
@@ -225,9 +252,8 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
dst.put(this.buffer);
this.buffer.limit(oldLimit);
return len;
- } else {
- dst.put(this.buffer);
}
+ dst.put(this.buffer);
return chunk;
}
@@ -269,7 +295,7 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
@Override
public boolean readLine(
- final CharArrayBuffer linebuffer,
+ final CharArrayBuffer lineBuffer,
final boolean endOfStream) throws CharacterCodingException {
setOutputMode();
@@ -306,41 +332,41 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
final int requiredCapacity = this.buffer.limit() - this.buffer.position();
// Ensure capacity of len assuming ASCII as the most likely charset
- linebuffer.ensureCapacity(requiredCapacity);
+ lineBuffer.ensureCapacity(requiredCapacity);
- if (this.chardecoder == null) {
+ if (this.charDecoder == null) {
if (this.buffer.hasArray()) {
final byte[] b = this.buffer.array();
final int off = this.buffer.position();
final int len = this.buffer.remaining();
- linebuffer.append(b, off, len);
+ lineBuffer.append(b, off, len);
this.buffer.position(off + len);
} else {
while (this.buffer.hasRemaining()) {
- linebuffer.append((char) (this.buffer.get() & 0xff));
+ lineBuffer.append((char) (this.buffer.get() & 0xff));
}
}
} else {
- if (this.charbuffer == null) {
- this.charbuffer = CharBuffer.allocate(this.lineBuffersize);
+ if (this.charBuffer == null) {
+ this.charBuffer = CharBuffer.allocate(this.lineBufferSize);
}
- this.chardecoder.reset();
+ this.charDecoder.reset();
for (;;) {
- final CoderResult result = this.chardecoder.decode(
+ final CoderResult result = this.charDecoder.decode(
this.buffer,
- this.charbuffer,
+ this.charBuffer,
true);
if (result.isError()) {
result.throwException();
}
if (result.isOverflow()) {
- this.charbuffer.flip();
- linebuffer.append(
- this.charbuffer.array(),
- this.charbuffer.position(),
- this.charbuffer.remaining());
- this.charbuffer.clear();
+ this.charBuffer.flip();
+ lineBuffer.append(
+ this.charBuffer.array(),
+ this.charBuffer.position(),
+ this.charBuffer.remaining());
+ this.charBuffer.clear();
}
if (result.isUnderflow()) {
break;
@@ -348,31 +374,31 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
}
// flush the decoder
- this.chardecoder.flush(this.charbuffer);
- this.charbuffer.flip();
+ this.charDecoder.flush(this.charBuffer);
+ this.charBuffer.flip();
// append the decoded content to the line buffer
- if (this.charbuffer.hasRemaining()) {
- linebuffer.append(
- this.charbuffer.array(),
- this.charbuffer.position(),
- this.charbuffer.remaining());
+ if (this.charBuffer.hasRemaining()) {
+ lineBuffer.append(
+ this.charBuffer.array(),
+ this.charBuffer.position(),
+ this.charBuffer.remaining());
}
}
this.buffer.limit(origLimit);
// discard LF if found
- int l = linebuffer.length();
- if (l > 0) {
- if (linebuffer.charAt(l - 1) == HTTP.LF) {
- l--;
- linebuffer.setLength(l);
+ int len = lineBuffer.length();
+ if (len > 0) {
+ if (lineBuffer.charAt(len - 1) == HTTP.LF) {
+ len--;
+ lineBuffer.setLength(len);
}
// discard CR if found
- if (l > 0) {
- if (linebuffer.charAt(l - 1) == HTTP.CR) {
- l--;
- linebuffer.setLength(l);
+ if (len > 0) {
+ if (lineBuffer.charAt(len - 1) == HTTP.CR) {
+ len--;
+ lineBuffer.setLength(len);
}
}
}
@@ -381,13 +407,9 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
@Override
public String readLine(final boolean endOfStream) throws CharacterCodingException {
- final CharArrayBuffer buffer = new CharArrayBuffer(64);
- final boolean found = readLine(buffer, endOfStream);
- if (found) {
- return buffer.toString();
- } else {
- return null;
- }
+ final CharArrayBuffer tmpBuffer = new CharArrayBuffer(64);
+ final boolean found = readLine(tmpBuffer, endOfStream);
+ return found ? tmpBuffer.toString() : null;
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java
index 73f063b..1114538 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java
@@ -60,18 +60,18 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
private static final byte[] CRLF = new byte[] {HTTP.CR, HTTP.LF};
- private final CharsetEncoder charencoder;
- private final int lineBuffersize;
+ private final CharsetEncoder charEncoder;
+ private final int lineBufferSize;
- private CharBuffer charbuffer;
+ private CharBuffer charBuffer;
/**
* Creates SessionOutputBufferImpl instance.
*
- * @param buffersize input buffer size
- * @param lineBuffersize buffer size for line operations. Has effect only if
- * {@code charencoder} is not {@code null}.
- * @param charencoder charencoder to be used for encoding HTTP protocol elements.
+ * @param bufferSize input buffer size.
+ * @param lineBufferSize buffer size for line operations. Has effect only if
+ * {@code charEncoder} is not {@code null}.
+ * @param charEncoder CharEncoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param allocator memory allocator.
* If {@code null} {@link HeapByteBufferAllocator#INSTANCE} will be used.
@@ -79,13 +79,13 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
* @since 4.3
*/
public SessionOutputBufferImpl(
- final int buffersize,
- final int lineBuffersize,
- final CharsetEncoder charencoder,
+ final int bufferSize,
+ final int lineBufferSize,
+ final CharsetEncoder charEncoder,
final ByteBufferAllocator allocator) {
- super(buffersize, allocator != null ? allocator : HeapByteBufferAllocator.INSTANCE);
- this.lineBuffersize = Args.positive(lineBuffersize, "Line buffer size");
- this.charencoder = charencoder;
+ super(bufferSize, allocator != null ? allocator : HeapByteBufferAllocator.INSTANCE);
+ this.lineBufferSize = Args.positive(lineBufferSize, "Line buffer size");
+ this.charEncoder = charEncoder;
}
/**
@@ -95,24 +95,24 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
*/
@Deprecated
public SessionOutputBufferImpl(
- final int buffersize,
- final int lineBuffersize,
+ final int bufferSize,
+ final int lineBufferSize,
final ByteBufferAllocator allocator,
final HttpParams params) {
- super(buffersize, allocator);
- this.lineBuffersize = Args.positive(lineBuffersize, "Line buffer size");
+ super(bufferSize, allocator);
+ this.lineBufferSize = Args.positive(lineBufferSize, "Line buffer size");
final String charsetName = (String) params.getParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET);
final Charset charset = CharsetUtils.lookup(charsetName);
if (charset != null) {
- this.charencoder = charset.newEncoder();
+ this.charEncoder = charset.newEncoder();
final CodingErrorAction a1 = (CodingErrorAction) params.getParameter(
CoreProtocolPNames.HTTP_MALFORMED_INPUT_ACTION);
- this.charencoder.onMalformedInput(a1 != null ? a1 : CodingErrorAction.REPORT);
+ this.charEncoder.onMalformedInput(a1 != null ? a1 : CodingErrorAction.REPORT);
final CodingErrorAction a2 = (CodingErrorAction) params.getParameter(
CoreProtocolPNames.HTTP_UNMAPPABLE_INPUT_ACTION);
- this.charencoder.onUnmappableCharacter(a2 != null? a2 : CodingErrorAction.REPORT);
+ this.charEncoder.onUnmappableCharacter(a2 != null? a2 : CodingErrorAction.REPORT);
} else {
- this.charencoder = null;
+ this.charEncoder = null;
}
}
@@ -122,37 +122,53 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
*/
@Deprecated
public SessionOutputBufferImpl(
- final int buffersize,
- final int linebuffersize,
+ final int bufferSize,
+ final int lineBufferSize,
final HttpParams params) {
- this(buffersize, linebuffersize, HeapByteBufferAllocator.INSTANCE, params);
+ this(bufferSize, lineBufferSize, HeapByteBufferAllocator.INSTANCE, params);
}
/**
+ * Creates SessionOutputBufferImpl instance.
+ *
+ * @param bufferSize input buffer size.
* @since 4.3
*/
- public SessionOutputBufferImpl(final int buffersize) {
- this(buffersize, 256, null, HeapByteBufferAllocator.INSTANCE);
+ public SessionOutputBufferImpl(final int bufferSize) {
+ this(bufferSize, 256, null, HeapByteBufferAllocator.INSTANCE);
}
/**
+ * Creates SessionOutputBufferImpl instance.
+ *
+ * @param bufferSize input buffer size.
+ * @param lineBufferSize buffer size for line operations. Has effect only if
+ * {@code charset} is not {@code null}.
+ * @param charset Charset to be used for encoding HTTP protocol elements.
+ * If {@code null} simple type cast will be used for char to byte conversion.
+ *
* @since 4.3
*/
public SessionOutputBufferImpl(
- final int buffersize,
- final int linebuffersize,
+ final int bufferSize,
+ final int lineBufferSize,
final Charset charset) {
- this(buffersize, linebuffersize,
+ this(bufferSize, lineBufferSize,
charset != null ? charset.newEncoder() : null, HeapByteBufferAllocator.INSTANCE);
}
/**
+ * Creates SessionOutputBufferImpl instance.
+ *
+ * @param bufferSize input buffer size.
+ * @param lineBufferSize buffer size for line operations.
+ *
* @since 4.3
*/
public SessionOutputBufferImpl(
- final int buffersize,
- final int linebuffersize) {
- this(buffersize, linebuffersize, null, HeapByteBufferAllocator.INSTANCE);
+ final int bufferSize,
+ final int lineBufferSize) {
+ this(bufferSize, lineBufferSize, null, HeapByteBufferAllocator.INSTANCE);
}
public void reset(final HttpParams params) {
@@ -203,51 +219,51 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
}
@Override
- public void writeLine(final CharArrayBuffer linebuffer) throws CharacterCodingException {
- if (linebuffer == null) {
+ public void writeLine(final CharArrayBuffer lineBuffer) throws CharacterCodingException {
+ if (lineBuffer == null) {
return;
}
setInputMode();
// Do not bother if the buffer is empty
- if (linebuffer.length() > 0 ) {
- if (this.charencoder == null) {
- final int requiredCapacity = this.buffer.position() + linebuffer.length();
+ if (lineBuffer.length() > 0 ) {
+ if (this.charEncoder == null) {
+ final int requiredCapacity = this.buffer.position() + lineBuffer.length();
ensureCapacity(requiredCapacity);
if (this.buffer.hasArray()) {
final byte[] b = this.buffer.array();
- final int len = linebuffer.length();
+ final int len = lineBuffer.length();
final int off = this.buffer.position();
for (int i = 0; i < len; i++) {
- b[off + i] = (byte) linebuffer.charAt(i);
+ b[off + i] = (byte) lineBuffer.charAt(i);
}
this.buffer.position(off + len);
} else {
- for (int i = 0; i < linebuffer.length(); i++) {
- this.buffer.put((byte) linebuffer.charAt(i));
+ for (int i = 0; i < lineBuffer.length(); i++) {
+ this.buffer.put((byte) lineBuffer.charAt(i));
}
}
} else {
- if (this.charbuffer == null) {
- this.charbuffer = CharBuffer.allocate(this.lineBuffersize);
+ if (this.charBuffer == null) {
+ this.charBuffer = CharBuffer.allocate(this.lineBufferSize);
}
- this.charencoder.reset();
+ this.charEncoder.reset();
// transfer the string in small chunks
- int remaining = linebuffer.length();
+ int remaining = lineBuffer.length();
int offset = 0;
while (remaining > 0) {
- int l = this.charbuffer.remaining();
+ int l = this.charBuffer.remaining();
boolean eol = false;
if (remaining <= l) {
l = remaining;
// terminate the encoding process
eol = true;
}
- this.charbuffer.put(linebuffer.buffer(), offset, l);
- this.charbuffer.flip();
+ this.charBuffer.put(lineBuffer.buffer(), offset, l);
+ this.charBuffer.flip();
boolean retry = true;
while (retry) {
- final CoderResult result = this.charencoder.encode(this.charbuffer, this.buffer, eol);
+ final CoderResult result = this.charEncoder.encode(this.charBuffer, this.buffer, eol);
if (result.isError()) {
result.throwException();
}
@@ -256,14 +272,14 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
}
retry = !result.isUnderflow();
}
- this.charbuffer.compact();
+ this.charBuffer.compact();
offset += l;
remaining -= l;
}
// flush the encoder
boolean retry = true;
while (retry) {
- final CoderResult result = this.charencoder.flush(this.buffer);
+ final CoderResult result = this.charEncoder.flush(this.buffer);
if (result.isError()) {
result.throwException();
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java/org/apache/http/nio/entity/EntityAsyncContentProducer.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/entity/EntityAsyncContentProducer.java b/httpcore-nio/src/main/java/org/apache/http/nio/entity/EntityAsyncContentProducer.java
index 40c4ea2..a1445bb 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/entity/EntityAsyncContentProducer.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/entity/EntityAsyncContentProducer.java
@@ -88,8 +88,8 @@ public class EntityAsyncContentProducer implements HttpAsyncContentProducer {
local.close();
}
if (this.entity.isStreaming()) {
- final InputStream instream = this.entity.getContent();
- instream.close();
+ final InputStream inStream = this.entity.getContent();
+ inStream.close();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java/org/apache/http/nio/entity/NByteArrayEntity.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/entity/NByteArrayEntity.java b/httpcore-nio/src/main/java/org/apache/http/nio/entity/NByteArrayEntity.java
index bd39aaa..79749c0 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/entity/NByteArrayEntity.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/entity/NByteArrayEntity.java
@@ -160,10 +160,10 @@ public class NByteArrayEntity extends AbstractHttpEntity
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- outstream.write(this.b, this.off, this.len);
- outstream.flush();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ outStream.write(this.b, this.off, this.len);
+ outStream.flush();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java b/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
index 7da8719..29d9a22 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
@@ -196,18 +196,18 @@ public class NFileEntity extends AbstractHttpEntity
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = new FileInputStream(this.file);
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final InputStream inStream = new FileInputStream(this.file);
try {
final byte[] tmp = new byte[4096];
int l;
- while ((l = instream.read(tmp)) != -1) {
- outstream.write(tmp, 0, l);
+ while ((l = inStream.read(tmp)) != -1) {
+ outStream.write(tmp, 0, l);
}
- outstream.flush();
+ outStream.flush();
} finally {
- instream.close();
+ inStream.close();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java b/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java
index b14fc66..d19ffb1 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java
@@ -189,10 +189,10 @@ public class NStringEntity extends AbstractHttpEntity
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- outstream.write(this.b);
- outstream.flush();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ outStream.write(this.b);
+ outStream.flush();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java/org/apache/http/nio/util/ExpandableBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/util/ExpandableBuffer.java b/httpcore-nio/src/main/java/org/apache/http/nio/util/ExpandableBuffer.java
index 71f2dac..0c71b70 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/util/ExpandableBuffer.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/util/ExpandableBuffer.java
@@ -56,14 +56,14 @@ public class ExpandableBuffer implements BufferInfo, org.apache.http.nio.util.Bu
/**
* Allocates buffer of the given size using the given allocator.
*
- * @param buffersize the buffer size.
+ * @param bufferSize the buffer size.
* @param allocator allocator to be used to allocate {@link ByteBuffer}s.
*/
- public ExpandableBuffer(final int buffersize, final ByteBufferAllocator allocator) {
+ public ExpandableBuffer(final int bufferSize, final ByteBufferAllocator allocator) {
super();
Args.notNull(allocator, "ByteBuffer allocator");
this.allocator = allocator;
- this.buffer = allocator.allocate(buffersize);
+ this.buffer = allocator.allocate(bufferSize);
this.mode = INPUT_MODE;
}
@@ -117,8 +117,8 @@ public class ExpandableBuffer implements BufferInfo, org.apache.http.nio.util.Bu
* @throws BufferOverflowException in case we get over the maximum allowed value
*/
protected void expand() throws BufferOverflowException {
- int newcapacity = (this.buffer.capacity() + 1) << 1;
- if (newcapacity < 0) {
+ int newCapacity = (this.buffer.capacity() + 1) << 1;
+ if (newCapacity < 0) {
final int vmBytes = Long.SIZE >> 3;
final int javaBytes = 8; // this is to be checked when the JVM version changes
@SuppressWarnings("unused") // we really need the 8 if we're going to make this foolproof
@@ -131,13 +131,13 @@ public class ExpandableBuffer implements BufferInfo, org.apache.http.nio.util.Bu
//
// WARNING: This code assumes you are providing enough heap room with -Xmx.
// source of inspiration: https://bugs.openjdk.java.net/browse/JDK-8059914
- newcapacity = Integer.MAX_VALUE - headRoom;
+ newCapacity = Integer.MAX_VALUE - headRoom;
- if (newcapacity <= this.buffer.capacity()) {
+ if (newCapacity <= this.buffer.capacity()) {
throw new BufferOverflowException();
}
}
- expandCapacity(newcapacity);
+ expandCapacity(newCapacity);
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedInputBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedInputBuffer.java b/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedInputBuffer.java
index 3d7723e..72aa021 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedInputBuffer.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedInputBuffer.java
@@ -66,8 +66,8 @@ public class SharedInputBuffer extends ExpandableBuffer implements ContentInputB
* @deprecated (4.3) use {@link SharedInputBuffer#SharedInputBuffer(int, ByteBufferAllocator)}
*/
@Deprecated
- public SharedInputBuffer(final int buffersize, final IOControl ioctrl, final ByteBufferAllocator allocator) {
- super(buffersize, allocator);
+ public SharedInputBuffer(final int bufferSize, final IOControl ioctrl, final ByteBufferAllocator allocator) {
+ super(bufferSize, allocator);
this.ioctrl = ioctrl;
this.lock = new ReentrantLock();
this.condition = this.lock.newCondition();
@@ -76,8 +76,8 @@ public class SharedInputBuffer extends ExpandableBuffer implements ContentInputB
/**
* @since 4.3
*/
- public SharedInputBuffer(final int buffersize, final ByteBufferAllocator allocator) {
- super(buffersize, allocator);
+ public SharedInputBuffer(final int bufferSize, final ByteBufferAllocator allocator) {
+ super(bufferSize, allocator);
this.lock = new ReentrantLock();
this.condition = this.lock.newCondition();
}
@@ -85,8 +85,8 @@ public class SharedInputBuffer extends ExpandableBuffer implements ContentInputB
/**
* @since 4.3
*/
- public SharedInputBuffer(final int buffersize) {
- this(buffersize, HeapByteBufferAllocator.INSTANCE);
+ public SharedInputBuffer(final int bufferSize) {
+ this(bufferSize, HeapByteBufferAllocator.INSTANCE);
}
@Override
@@ -142,13 +142,8 @@ public class SharedInputBuffer extends ExpandableBuffer implements ContentInputB
if (totalRead > 0) {
return totalRead;
- } else {
- if (this.endOfStream) {
- return -1;
- } else {
- return 0;
- }
}
+ return this.endOfStream ? -1 : 0;
} finally {
this.lock.unlock();
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java b/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java
index 9bcccd5..98b8a75 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java
@@ -68,8 +68,8 @@ public class SharedOutputBuffer extends ExpandableBuffer implements ContentOutpu
* @deprecated (4.3) use {@link SharedOutputBuffer#SharedOutputBuffer(int, ByteBufferAllocator)}
*/
@Deprecated
- public SharedOutputBuffer(final int buffersize, final IOControl ioctrl, final ByteBufferAllocator allocator) {
- super(buffersize, allocator);
+ public SharedOutputBuffer(final int bufferSize, final IOControl ioctrl, final ByteBufferAllocator allocator) {
+ super(bufferSize, allocator);
Args.notNull(ioctrl, "I/O content control");
this.ioctrl = ioctrl;
this.lock = new ReentrantLock();
@@ -79,8 +79,8 @@ public class SharedOutputBuffer extends ExpandableBuffer implements ContentOutpu
/**
* @since 4.3
*/
- public SharedOutputBuffer(final int buffersize, final ByteBufferAllocator allocator) {
- super(buffersize, allocator);
+ public SharedOutputBuffer(final int bufferSize, final ByteBufferAllocator allocator) {
+ super(bufferSize, allocator);
this.lock = new ReentrantLock();
this.condition = this.lock.newCondition();
}
@@ -88,8 +88,8 @@ public class SharedOutputBuffer extends ExpandableBuffer implements ContentOutpu
/**
* @since 4.3
*/
- public SharedOutputBuffer(final int buffersize) {
- this(buffersize, HeapByteBufferAllocator.INSTANCE);
+ public SharedOutputBuffer(final int bufferSize) {
+ this(bufferSize, HeapByteBufferAllocator.INSTANCE);
}
@Override
@@ -263,6 +263,7 @@ public class SharedOutputBuffer extends ExpandableBuffer implements ContentOutpu
@Override
public void flush() throws IOException {
+ // do nothing.
}
private void flushContent() throws IOException {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleInputBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleInputBuffer.java b/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleInputBuffer.java
index ed352e4..834bdad 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleInputBuffer.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleInputBuffer.java
@@ -41,15 +41,15 @@ public class SimpleInputBuffer extends ExpandableBuffer implements ContentInputB
private boolean endOfStream = false;
- public SimpleInputBuffer(final int buffersize, final ByteBufferAllocator allocator) {
- super(buffersize, allocator);
+ public SimpleInputBuffer(final int bufferSize, final ByteBufferAllocator allocator) {
+ super(bufferSize, allocator);
}
/**
* @since 4.3
*/
- public SimpleInputBuffer(final int buffersize) {
- this(buffersize, HeapByteBufferAllocator.INSTANCE);
+ public SimpleInputBuffer(final int bufferSize) {
+ this(bufferSize, HeapByteBufferAllocator.INSTANCE);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleOutputBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleOutputBuffer.java b/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleOutputBuffer.java
index d3416d2..b1080fc 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleOutputBuffer.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/util/SimpleOutputBuffer.java
@@ -41,16 +41,16 @@ public class SimpleOutputBuffer extends ExpandableBuffer implements ContentOutpu
private boolean endOfStream;
- public SimpleOutputBuffer(final int buffersize, final ByteBufferAllocator allocator) {
- super(buffersize, allocator);
+ public SimpleOutputBuffer(final int bufferSize, final ByteBufferAllocator allocator) {
+ super(bufferSize, allocator);
this.endOfStream = false;
}
/**
* @since 4.3
*/
- public SimpleOutputBuffer(final int buffersize) {
- this(buffersize, HeapByteBufferAllocator.INSTANCE);
+ public SimpleOutputBuffer(final int bufferSize) {
+ this(bufferSize, HeapByteBufferAllocator.INSTANCE);
}
@Override
@@ -104,6 +104,7 @@ public class SimpleOutputBuffer extends ExpandableBuffer implements ContentOutpu
@Override
public void flush() {
+ // do nothing.
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/test/java/org/apache/http/WritableByteChannelMock.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/WritableByteChannelMock.java b/httpcore-nio/src/test/java/org/apache/http/WritableByteChannelMock.java
index b519306..35d4d8d 100644
--- a/httpcore-nio/src/test/java/org/apache/http/WritableByteChannelMock.java
+++ b/httpcore-nio/src/test/java/org/apache/http/WritableByteChannelMock.java
@@ -43,8 +43,8 @@ public class WritableByteChannelMock implements WritableByteChannel {
private final int capacityLimit;
private int curCapacity;
- public InternalBuffer(final int buffersize, final int capacityLimit) {
- super(buffersize, HeapByteBufferAllocator.INSTANCE);
+ public InternalBuffer(final int bufferSize, final int capacityLimit) {
+ super(bufferSize, HeapByteBufferAllocator.INSTANCE);
this.capacityLimit = capacityLimit;
this.curCapacity = capacityLimit;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java b/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java
index d4e9b95..c9d5bf9 100644
--- a/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java
+++ b/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestSessionInOutBuffers.java
@@ -77,8 +77,8 @@ public class TestSessionInOutBuffers {
new Object[] { DirectByteBufferAllocator.INSTANCE });
}
- private static WritableByteChannel newChannel(final ByteArrayOutputStream outstream) {
- return Channels.newChannel(outstream);
+ private static WritableByteChannel newChannel(final ByteArrayOutputStream outStream) {
+ return Channels.newChannel(outStream);
}
private static ReadableByteChannel newChannel(final byte[] bytes) {
@@ -223,11 +223,11 @@ public class TestSessionInOutBuffers {
line.clear();
Assert.assertFalse(inbuf.readLine(line, true));
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- final WritableByteChannel outChannel = newChannel(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ final WritableByteChannel outChannel = newChannel(outStream);
outbuf.flush(outChannel);
- final String s = new String(outstream.toByteArray(), "US-ASCII");
+ final String s = new String(outStream.toByteArray(), "US-ASCII");
Assert.assertEquals("One\r\nTwo\r\nThree\r\nFour\r\n", s);
}
@@ -255,11 +255,11 @@ public class TestSessionInOutBuffers {
outbuf.writeLine((String)null);
outbuf.writeLine((CharArrayBuffer)null);
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- final WritableByteChannel outChannel = newChannel(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ final WritableByteChannel outChannel = newChannel(outStream);
outbuf.flush(outChannel);
- final ReadableByteChannel channel = newChannel(outstream.toByteArray());
+ final ReadableByteChannel channel = newChannel(outStream.toByteArray());
final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 16, null, this.allocator);
inbuf.fill(channel);
@@ -305,11 +305,11 @@ public class TestSessionInOutBuffers {
outbuf.write(ByteBuffer.wrap(new byte[] {'a'}));
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- final WritableByteChannel outChannel = newChannel(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ final WritableByteChannel outChannel = newChannel(outStream);
outbuf.flush(outChannel);
- final ReadableByteChannel channel = newChannel(outstream.toByteArray());
+ final ReadableByteChannel channel = newChannel(outStream.toByteArray());
final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 16, null, this.allocator);
inbuf.fill(channel);
@@ -392,11 +392,11 @@ public class TestSessionInOutBuffers {
while (inbuf.fill(channel) > 0) {
}
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- final WritableByteChannel dst = newChannel(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ final WritableByteChannel dst = newChannel(outStream);
Assert.assertEquals(16, inbuf.read(dst));
- Assert.assertEquals(ByteBuffer.wrap(pattern), ByteBuffer.wrap(outstream.toByteArray()));
+ Assert.assertEquals(ByteBuffer.wrap(pattern), ByteBuffer.wrap(outStream.toByteArray()));
}
@Test
@@ -407,13 +407,13 @@ public class TestSessionInOutBuffers {
while (inbuf.fill(channel) > 0) {
}
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- final WritableByteChannel dst = newChannel(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ final WritableByteChannel dst = newChannel(outStream);
Assert.assertEquals(10, inbuf.read(dst, 10));
Assert.assertEquals(3, inbuf.read(dst, 3));
Assert.assertEquals(3, inbuf.read(dst, 10));
- Assert.assertEquals(ByteBuffer.wrap(pattern), ByteBuffer.wrap(outstream.toByteArray()));
+ Assert.assertEquals(ByteBuffer.wrap(pattern), ByteBuffer.wrap(outStream.toByteArray()));
}
@Test
@@ -424,11 +424,11 @@ public class TestSessionInOutBuffers {
final ReadableByteChannel src = newChannel(pattern);
outbuf.write(src);
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- final WritableByteChannel channel = newChannel(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ final WritableByteChannel channel = newChannel(outStream);
while (outbuf.flush(channel) > 0) {
}
- Assert.assertEquals(ByteBuffer.wrap(pattern), ByteBuffer.wrap(outstream.toByteArray()));
+ Assert.assertEquals(ByteBuffer.wrap(pattern), ByteBuffer.wrap(outStream.toByteArray()));
}
@Test
@@ -440,11 +440,11 @@ public class TestSessionInOutBuffers {
outbuf.write(ByteBuffer.wrap(pattern, 16, 10));
outbuf.write(ByteBuffer.wrap(pattern, 26, 6));
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- final WritableByteChannel channel = newChannel(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ final WritableByteChannel channel = newChannel(outStream);
while (outbuf.flush(channel) > 0) {
}
- Assert.assertEquals(ByteBuffer.wrap(pattern), ByteBuffer.wrap(outstream.toByteArray()));
+ Assert.assertEquals(ByteBuffer.wrap(pattern), ByteBuffer.wrap(outStream.toByteArray()));
}
static final int SWISS_GERMAN_HELLO [] = {
@@ -481,11 +481,11 @@ public class TestSessionInOutBuffers {
outbuf.writeLine(s3);
}
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- final WritableByteChannel outChannel = newChannel(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ final WritableByteChannel outChannel = newChannel(outStream);
outbuf.flush(outChannel);
- final byte[] tmp = outstream.toByteArray();
+ final byte[] tmp = outStream.toByteArray();
final ReadableByteChannel channel = newChannel(tmp);
final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16,
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlerCancellable.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlerCancellable.java b/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlerCancellable.java
index 1946afe..2524888 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlerCancellable.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlerCancellable.java
@@ -136,8 +136,8 @@ public class TestHttpAsyncHandlerCancellable extends HttpCoreNIOTestBase {
final InetSocketAddress address = (InetSocketAddress) endpoint.getAddress();
final Socket socket = new Socket("localhost", address.getPort());
try {
- final OutputStream outstream = socket.getOutputStream();
- final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outstream, "US-ASCII"));
+ final OutputStream outStream = socket.getOutputStream();
+ final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outStream, "US-ASCII"));
writer.write("GET /long HTTP/1.1\r\n");
writer.write("Host: localhost\r\n");
writer.write("\r\n");
@@ -194,8 +194,8 @@ public class TestHttpAsyncHandlerCancellable extends HttpCoreNIOTestBase {
final InetSocketAddress address = (InetSocketAddress) endpoint.getAddress();
final Socket socket = new Socket("localhost", address.getPort());
try {
- final OutputStream outstream = socket.getOutputStream();
- final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outstream, "US-ASCII"));
+ final OutputStream outStream = socket.getOutputStream();
+ final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outStream, "US-ASCII"));
writer.write("GET /long HTTP/1.1\r\n");
writer.write("Host: localhost\r\n");
writer.write("\r\n");
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestServerSidePipelining.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestServerSidePipelining.java b/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestServerSidePipelining.java
index 25f9ab6..1a45073 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestServerSidePipelining.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestServerSidePipelining.java
@@ -137,8 +137,8 @@ public class TestServerSidePipelining extends HttpCoreNIOTestBase {
final InetSocketAddress address = (InetSocketAddress) endpoint.getAddress();
final Socket socket = new Socket("localhost", address.getPort());
try {
- final OutputStream outstream = socket.getOutputStream();
- final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outstream, "US-ASCII"));
+ final OutputStream outStream = socket.getOutputStream();
+ final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outStream, "US-ASCII"));
writer.write("GET / HTTP/1.1\r\n");
writer.write("Host: localhost\r\n");
writer.write("\r\n");
@@ -153,8 +153,8 @@ public class TestServerSidePipelining extends HttpCoreNIOTestBase {
writer.write("Connection: close\r\n");
writer.write("\r\n");
writer.flush();
- final InputStream instream = socket.getInputStream();
- final BufferedReader reader = new BufferedReader(new InputStreamReader(instream, "US-ASCII"));
+ final InputStream inStream = socket.getInputStream();
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, "US-ASCII"));
final StringBuilder buf = new StringBuilder();
final char[] tmp = new char[1024];
int l;
@@ -207,8 +207,8 @@ public class TestServerSidePipelining extends HttpCoreNIOTestBase {
final InetSocketAddress address = (InetSocketAddress) endpoint.getAddress();
final Socket socket = new Socket("localhost", address.getPort());
try {
- final OutputStream outstream = socket.getOutputStream();
- final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outstream, "US-ASCII"));
+ final OutputStream outStream = socket.getOutputStream();
+ final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outStream, "US-ASCII"));
writer.write("POST /echo HTTP/1.1\r\n");
writer.write("Host: localhost\r\n");
writer.write("Content-Length: 16\r\n");
@@ -232,8 +232,8 @@ public class TestServerSidePipelining extends HttpCoreNIOTestBase {
writer.write("Host: localhost\r\n");
writer.write("\r\n");
writer.flush();
- final InputStream instream = socket.getInputStream();
- final BufferedReader reader = new BufferedReader(new InputStreamReader(instream, "US-ASCII"));
+ final InputStream inStream = socket.getInputStream();
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, "US-ASCII"));
final StringBuilder buf = new StringBuilder();
final char[] tmp = new char[1024];
int l;
@@ -286,8 +286,8 @@ public class TestServerSidePipelining extends HttpCoreNIOTestBase {
final InetSocketAddress address = (InetSocketAddress) endpoint.getAddress();
final Socket socket = new Socket("localhost", address.getPort());
try {
- final OutputStream outstream = socket.getOutputStream();
- final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outstream, "US-ASCII"));
+ final OutputStream outStream = socket.getOutputStream();
+ final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outStream, "US-ASCII"));
writer.write("POST /echo HTTP/1.1\r\n");
writer.write("Host: localhost\r\n");
writer.write("Expect: 100-Continue\r\n");
@@ -311,8 +311,8 @@ public class TestServerSidePipelining extends HttpCoreNIOTestBase {
writer.write("\r\n");
writer.write("booo booo booo\r\n");
writer.flush();
- final InputStream instream = socket.getInputStream();
- final BufferedReader reader = new BufferedReader(new InputStreamReader(instream, "US-ASCII"));
+ final InputStream inStream = socket.getInputStream();
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, "US-ASCII"));
final StringBuilder buf = new StringBuilder();
final char[] tmp = new char[1024];
int l;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/9dc8fe89/httpcore-nio/src/test/java/org/apache/http/nio/util/TestBuffers.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/util/TestBuffers.java b/httpcore-nio/src/test/java/org/apache/http/nio/util/TestBuffers.java
index e33effa..2b760e6 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/util/TestBuffers.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/util/TestBuffers.java
@@ -86,8 +86,8 @@ public class TestBuffers {
@Test
public void testOutputBufferOperations() throws IOException {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- final WritableByteChannel channel = Channels.newChannel(outstream);
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ final WritableByteChannel channel = Channels.newChannel(outStream);
final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, Consts.ASCII);
final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
@@ -103,7 +103,7 @@ public class TestBuffers {
buffer.write(EncodingUtils.getAsciiBytes("stuff"));
buffer.produceContent(encoder);
- final byte[] content = outstream.toByteArray();
+ final byte[] content = outStream.toByteArray();
Assert.assertEquals("stuff;more stuff", EncodingUtils.getAsciiString(content));
}
[10/12] httpcomponents-core git commit: Pull up setter method to the
class where the ivar is actually defined.
Posted by ol...@apache.org.
Pull up setter method to the class where the ivar is actually defined.
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/2548f7c2
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/2548f7c2
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/2548f7c2
Branch: refs/heads/4.4.x
Commit: 2548f7c2d6a08f26f5694d75bd34cf36055304c6
Parents: ea64b18
Author: Gary Gregory <ga...@gmail.com>
Authored: Mon Aug 13 17:59:38 2018 -0600
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue Aug 14 09:49:35 2018 +0200
----------------------------------------------------------------------
.../http/impl/nio/codecs/AbstractContentDecoder.java | 14 ++++++++++++++
.../apache/http/impl/nio/codecs/IdentityDecoder.java | 11 -----------
2 files changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2548f7c2/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
index 3d65ace..0fcbd2c 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
@@ -77,6 +77,20 @@ public abstract class AbstractContentDecoder implements ContentDecoder {
}
/**
+ * Sets the completed status of this decoder. Normally this is not necessary
+ * (the decoder will automatically complete when the underlying channel
+ * returns EOF). It is useful to mark the decoder as completed if you have
+ * some other means to know all the necessary data has been read and want to
+ * reuse the underlying connection for more messages.
+ *
+ * @param completed the completed status of this decoder.
+ * @since 4.4.11
+ */
+ public void setCompleted(final boolean completed) {
+ this.completed = completed;
+ }
+
+ /**
* Reads from the channel to the destination.
*
* @param dst destination.
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/2548f7c2/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
index fe9311b..fddd480 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/codecs/IdentityDecoder.java
@@ -59,17 +59,6 @@ public class IdentityDecoder extends AbstractContentDecoder
super(channel, buffer, metrics);
}
- /**
- * Sets the completed status of this decoder. Normally this is not necessary
- * (the decoder will automatically complete when the underlying channel
- * returns EOF). It is useful to mark the decoder as completed if you have
- * some other means to know all the necessary data has been read and want to
- * reuse the underlying connection for more messages.
- */
- public void setCompleted(final boolean completed) {
- this.completed = completed;
- }
-
@Override
public int read(final ByteBuffer dst) throws IOException {
Args.notNull(dst, "Byte buffer");