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:41 UTC
[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
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));
}