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/21 15:01:36 UTC
[25/32] httpcomponents-core git commit: - Always use blocks - Add
missing serial version ID (default 1L) - Camel-case names. - Don't nest in
else clause unnecessarily.
- Always use blocks
- Add missing serial version ID (default 1L)
- Camel-case names.
- Don't nest in else clause unnecessarily.
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/fc6be3e6
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/fc6be3e6
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/fc6be3e6
Branch: refs/heads/api_javadocs
Commit: fc6be3e60b81c2c31557b23df762c0bb61e5aedc
Parents: f5a28b9
Author: Gary Gregory <ga...@gmail.com>
Authored: Tue Aug 14 09:55:51 2018 -0600
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue Aug 14 20:47:20 2018 +0200
----------------------------------------------------------------------
.../hc/core5/http2/H2CorruptFrameException.java | 2 +
.../hc/core5/http2/hpack/HPackException.java | 2 +
.../hc/core5/benchmark/BenchmarkWorker.java | 6 +-
.../classic/LoggingBHttpClientConnection.java | 22 +-
.../classic/LoggingBHttpServerConnection.java | 22 +-
.../hc/core5/testing/nio/LoggingIOSession.java | 16 +-
.../hc/core5/testing/nio/Http2ALPNTest.java | 245 -------------------
.../hc/core5/testing/nio/Http2AlpnTest.java | 241 ++++++++++++++++++
.../nio/TestDefaultListeningIOReactor.java | 38 +--
.../http/ConnectionRequestTimeoutException.java | 2 +
.../core5/http/MethodNotSupportedException.java | 2 +
.../core5/http/MisdirectedRequestException.java | 2 +
.../hc/core5/http/StreamClosedException.java | 2 +
.../core5/http/impl/io/BHttpConnectionBase.java | 8 +-
.../impl/io/DefaultBHttpClientConnection.java | 16 +-
.../impl/io/DefaultBHttpServerConnection.java | 16 +-
.../http/impl/io/SessionInputBufferImpl.java | 6 +-
.../http/impl/io/SessionOutputBufferImpl.java | 6 +-
.../http/impl/nio/SessionInputBufferImpl.java | 18 +-
.../http/impl/nio/SessionOutputBufferImpl.java | 18 +-
.../http/message/BasicClassicHttpResponse.java | 1 +
.../main/java/org/apache/hc/core5/net/Host.java | 1 +
.../org/apache/hc/core5/net/URIAuthority.java | 1 +
.../reactor/IOReactorShutdownException.java | 2 +
.../hc/core5/reactor/ssl/SSLManagedBuffer.java | 6 +-
25 files changed, 355 insertions(+), 346 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2CorruptFrameException.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2CorruptFrameException.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2CorruptFrameException.java
index 275a9cb..fb3b374 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2CorruptFrameException.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2CorruptFrameException.java
@@ -30,6 +30,8 @@ import java.io.IOException;
public class H2CorruptFrameException extends IOException {
+ private static final long serialVersionUID = 1L;
+
public H2CorruptFrameException(final String message) {
super(message);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackException.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackException.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackException.java
index 224d6d6..55dc85c 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackException.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackException.java
@@ -30,6 +30,8 @@ import org.apache.hc.core5.http.HttpException;
public class HPackException extends HttpException {
+ private static final long serialVersionUID = 1L;
+
public HPackException(final String message) {
super(message);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java
index a1b7eca..f6b33a5 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java
@@ -181,18 +181,18 @@ class BenchmarkWorker implements Runnable {
if (charset == null) {
charset = StandardCharsets.ISO_8859_1;
}
- long contentlen = 0;
+ long contentLen = 0;
final InputStream inStream = entity.getContent();
int l;
while ((l = inStream.read(this.buffer)) != -1) {
- contentlen += l;
+ contentLen += l;
if (config.getVerbosity() >= 4) {
final String s = new String(this.buffer, 0, l, charset);
System.out.print(s);
}
}
inStream.close();
- stats.setContentLength(contentlen);
+ stats.setContentLength(contentLen);
}
if (config.getVerbosity() >= 4) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpClientConnection.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpClientConnection.java
index 6e16760..a472848 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpClientConnection.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpClientConnection.java
@@ -55,23 +55,23 @@ public class LoggingBHttpClientConnection extends DefaultBHttpClientConnection i
private final String id;
private final Logger log;
- private final Logger headerlog;
+ private final Logger headerLog;
private final Wire wire;
public LoggingBHttpClientConnection(
final H1Config h1Config,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
- super(h1Config, chardecoder, charencoder,
+ super(h1Config, charDecoder, charEncoder,
incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.id = "http-outgoing-" + COUNT.incrementAndGet();
this.log = LoggerFactory.getLogger(getClass());
- this.headerlog = LoggerFactory.getLogger("org.apache.hc.core5.http.headers");
+ this.headerLog = LoggerFactory.getLogger("org.apache.hc.core5.http.headers");
this.wire = new Wire(LoggerFactory.getLogger("org.apache.hc.core5.http.wire"), this.id);
}
@@ -107,22 +107,22 @@ public class LoggingBHttpClientConnection extends DefaultBHttpClientConnection i
@Override
protected void onResponseReceived(final ClassicHttpResponse response) {
- if (response != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(this.id + " << " + new StatusLine(response));
+ if (response != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(this.id + " << " + new StatusLine(response));
final Header[] headers = response.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(this.id + " << " + header.toString());
+ this.headerLog.debug(this.id + " << " + header.toString());
}
}
}
@Override
protected void onRequestSubmitted(final ClassicHttpRequest request) {
- if (request != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(id + " >> " + new RequestLine(request));
+ if (request != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(id + " >> " + new RequestLine(request));
final Header[] headers = request.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(this.id + " >> " + header.toString());
+ this.headerLog.debug(this.id + " >> " + header.toString());
}
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpServerConnection.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpServerConnection.java
index 48279d5..74065a4 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpServerConnection.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpServerConnection.java
@@ -54,24 +54,24 @@ public class LoggingBHttpServerConnection extends DefaultBHttpServerConnection i
private final String id;
private final Logger log;
- private final Logger headerlog;
+ private final Logger headerLog;
private final Wire wire;
public LoggingBHttpServerConnection(
final String scheme,
final H1Config h1Config,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageParserFactory<ClassicHttpRequest> requestParserFactory,
final HttpMessageWriterFactory<ClassicHttpResponse> responseWriterFactory) {
- super(scheme, h1Config, chardecoder, charencoder,
+ super(scheme, h1Config, charDecoder, charEncoder,
incomingContentStrategy, outgoingContentStrategy,
requestParserFactory, responseWriterFactory);
this.id = "http-incoming-" + COUNT.incrementAndGet();
this.log = LoggerFactory.getLogger(getClass());
- this.headerlog = LoggerFactory.getLogger("org.apache.hc.core5.http.headers");
+ this.headerLog = LoggerFactory.getLogger("org.apache.hc.core5.http.headers");
this.wire = new Wire(LoggerFactory.getLogger("org.apache.hc.core5.http.wire"), this.id);
}
@@ -107,22 +107,22 @@ public class LoggingBHttpServerConnection extends DefaultBHttpServerConnection i
@Override
protected void onRequestReceived(final ClassicHttpRequest request) {
- if (request != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(id + " >> " + new RequestLine(request));
+ if (request != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(id + " >> " + new RequestLine(request));
final Header[] headers = request.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(this.id + " >> " + header.toString());
+ this.headerLog.debug(this.id + " >> " + header.toString());
}
}
}
@Override
protected void onResponseSubmitted(final ClassicHttpResponse response) {
- if (response != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(this.id + " << " + new StatusLine(response));
+ if (response != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(this.id + " << " + new StatusLine(response));
final Header[] headers = response.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(this.id + " << " + header.toString());
+ this.headerLog.debug(this.id + " << " + header.toString());
}
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java
index 40a977d..a1f1183 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java
@@ -43,16 +43,16 @@ import org.slf4j.Logger;
public class LoggingIOSession implements IOSession {
private final Logger log;
- private final Wire wirelog;
+ private final Wire wireLog;
private final IOSession session;
private final ByteChannel channel;
- public LoggingIOSession(final IOSession session, final Logger log, final Logger wirelog) {
+ public LoggingIOSession(final IOSession session, final Logger log, final Logger wireLog) {
super();
this.session = session;
this.log = log;
- this.wirelog = wirelog != null ? new Wire(wirelog, session.getId()) : null;
- this.channel = wirelog != null ? new LoggingByteChannel() : session.channel();
+ this.wireLog = wireLog != null ? new Wire(wireLog, session.getId()) : null;
+ this.channel = wireLog != null ? new LoggingByteChannel() : session.channel();
}
public LoggingIOSession(final IOSession session, final Logger log) {
@@ -222,12 +222,12 @@ public class LoggingIOSession implements IOSession {
if (log.isDebugEnabled()) {
log.debug(session + " " + bytesRead + " bytes read");
}
- if (bytesRead > 0 && wirelog.isEnabled()) {
+ if (bytesRead > 0 && wireLog.isEnabled()) {
final ByteBuffer b = dst.duplicate();
final int p = b.position();
b.limit(p);
b.position(p - bytesRead);
- wirelog.input(b);
+ wireLog.input(b);
}
return bytesRead;
}
@@ -238,12 +238,12 @@ public class LoggingIOSession implements IOSession {
if (log.isDebugEnabled()) {
log.debug(session + " " + byteWritten + " bytes written");
}
- if (byteWritten > 0 && wirelog.isEnabled()) {
+ if (byteWritten > 0 && wireLog.isEnabled()) {
final ByteBuffer b = src.duplicate();
final int p = b.position();
b.limit(p);
b.position(p - byteWritten);
- wirelog.output(b);
+ wireLog.output(b);
}
return byteWritten;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ALPNTest.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ALPNTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ALPNTest.java
deleted file mode 100644
index ead081c..0000000
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2ALPNTest.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.hc.core5.testing.nio;
-
-import java.net.InetSocketAddress;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-import org.apache.hc.core5.function.Supplier;
-import org.apache.hc.core5.http.ContentType;
-import org.apache.hc.core5.http.HttpException;
-import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.HttpResponse;
-import org.apache.hc.core5.http.HttpStatus;
-import org.apache.hc.core5.http.Message;
-import org.apache.hc.core5.http.URIScheme;
-import org.apache.hc.core5.http.impl.bootstrap.HttpAsyncServer;
-import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
-import org.apache.hc.core5.http.nio.BasicRequestProducer;
-import org.apache.hc.core5.http.nio.BasicResponseConsumer;
-import org.apache.hc.core5.http.nio.entity.StringAsyncEntityConsumer;
-import org.apache.hc.core5.http.nio.entity.StringAsyncEntityProducer;
-import org.apache.hc.core5.http.nio.ssl.BasicServerTlsStrategy;
-import org.apache.hc.core5.http2.impl.nio.bootstrap.H2ServerBootstrap;
-import org.apache.hc.core5.http2.impl.nio.bootstrap.Http2MultiplexingRequester;
-import org.apache.hc.core5.http2.impl.nio.bootstrap.Http2MultiplexingRequesterBootstrap;
-import org.apache.hc.core5.http2.ssl.H2ClientTlsStrategy;
-import org.apache.hc.core5.io.CloseMode;
-import org.apache.hc.core5.reactor.ExceptionEvent;
-import org.apache.hc.core5.reactor.IOReactorConfig;
-import org.apache.hc.core5.reactor.ListenerEndpoint;
-import org.apache.hc.core5.testing.SSLTestContexts;
-import org.apache.hc.core5.testing.TestingSupport;
-import org.apache.hc.core5.util.Timeout;
-import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.ExternalResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class Http2ALPNTest {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private static final Timeout TIMEOUT = Timeout.ofSeconds(30);
-
- private HttpAsyncServer server;
-
- @Rule
- public ExternalResource serverResource = new ExternalResource() {
-
- @Override
- protected void before() throws Throwable {
- log.debug("Starting up test server");
- server = H2ServerBootstrap.bootstrap()
- .setIOReactorConfig(
- IOReactorConfig.custom()
- .setSoTimeout(TIMEOUT)
- .build())
- .setTlsStrategy(new BasicServerTlsStrategy(
- SSLTestContexts.createServerSSLContext(),
- SecureAllPortsStrategy.INSTANCE))
- .setIOSessionListener(LoggingIOSessionListener.INSTANCE)
- .setIOSessionDecorator(LoggingIOSessionDecorator.INSTANCE)
- .setStreamListener(LoggingHttp2StreamListener.INSTANCE)
- .register("*", new Supplier<AsyncServerExchangeHandler>() {
-
- @Override
- public AsyncServerExchangeHandler get() {
- return new EchoHandler(2048);
- }
-
- })
- .create();
- }
-
- @Override
- protected void after() {
- log.debug("Shutting down test server");
- if (server != null) {
- try {
- server.close(CloseMode.GRACEFUL);
- final List<ExceptionEvent> exceptionLog = server.getExceptionLog();
- server = null;
- if (!exceptionLog.isEmpty()) {
- for (final ExceptionEvent event: exceptionLog) {
- final Throwable cause = event.getCause();
- log.error("Unexpected " + cause.getClass() + " at " + event.getTimestamp(), cause);
- }
- }
- } catch (final Exception ignore) {
- }
- }
- }
-
- };
-
- private Http2MultiplexingRequester requester;
-
- @Rule
- public ExternalResource clientResource = new ExternalResource() {
-
- @Override
- protected void after() {
- log.debug("Shutting down test client");
- if (requester != null) {
- try {
- requester.close(CloseMode.GRACEFUL);
- final List<ExceptionEvent> exceptionLog = requester.getExceptionLog();
- requester = null;
- if (!exceptionLog.isEmpty()) {
- for (final ExceptionEvent event: exceptionLog) {
- final Throwable cause = event.getCause();
- log.error("Unexpected " + cause.getClass() + " at " + event.getTimestamp(), cause);
- }
- }
- } catch (final Exception ignore) {
- }
- }
- }
-
- };
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private static int javaVersion;
-
- @BeforeClass
- public static void determineJavaVersion() {
- javaVersion = TestingSupport.determineJRELevel();
- }
-
- @Before
- public void checkVersion() {
- Assume.assumeTrue("Java version must be 9 or greater", javaVersion >= 9);
- }
-
- @Test
- public void testALPNLax() throws Exception {
- log.debug("Starting up test client");
- requester = Http2MultiplexingRequesterBootstrap.bootstrap()
- .setIOReactorConfig(IOReactorConfig.custom()
- .setSoTimeout(TIMEOUT)
- .build())
- .setTlsStrategy(new H2ClientTlsStrategy(SSLTestContexts.createClientSSLContext()))
- .setStrictALPNHandshake(false)
- .setIOSessionListener(LoggingIOSessionListener.INSTANCE)
- .setIOSessionDecorator(LoggingIOSessionDecorator.INSTANCE)
- .setStreamListener(LoggingHttp2StreamListener.INSTANCE)
- .create();
-
- server.start();
- final Future<ListenerEndpoint> future = server.listen(new InetSocketAddress(0));
- final ListenerEndpoint listener = future.get();
- final InetSocketAddress address = (InetSocketAddress) listener.getAddress();
- requester.start();
-
- final HttpHost target = new HttpHost("localhost", address.getPort(), URIScheme.HTTPS.id);
- final Future<Message<HttpResponse, String>> resultFuture1 = requester.execute(
- new BasicRequestProducer("POST", target, "/stuff",
- new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
- new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
- final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
- Assert.assertThat(message1, CoreMatchers.notNullValue());
- final HttpResponse response1 = message1.getHead();
- Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
- final String body1 = message1.getBody();
- Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
- }
-
- @Test()
- public void testALPNStrict() throws Exception {
-
- thrown.expect(HttpException.class);
- thrown.expectMessage("ALPN: missing application protocol");
-
- log.debug("Starting up test client");
- requester = Http2MultiplexingRequesterBootstrap.bootstrap()
- .setIOReactorConfig(IOReactorConfig.custom()
- .setSoTimeout(TIMEOUT)
- .build())
- .setTlsStrategy(new H2ClientTlsStrategy(SSLTestContexts.createClientSSLContext()))
- .setStrictALPNHandshake(true)
- .setIOSessionListener(LoggingIOSessionListener.INSTANCE)
- .setIOSessionDecorator(LoggingIOSessionDecorator.INSTANCE)
- .setStreamListener(LoggingHttp2StreamListener.INSTANCE)
- .create();
-
- server.start();
- final Future<ListenerEndpoint> future = server.listen(new InetSocketAddress(0));
- final ListenerEndpoint listener = future.get();
- final InetSocketAddress address = (InetSocketAddress) listener.getAddress();
- requester.start();
-
- final HttpHost target = new HttpHost("localhost", address.getPort(), URIScheme.HTTPS.id);
- final Future<Message<HttpResponse, String>> resultFuture1 = requester.execute(
- new BasicRequestProducer("POST", target, "/stuff",
- new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
- new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
- try {
- resultFuture1.get();
- Assert.fail("ExecutionException expected");
- } catch (final ExecutionException ex) {
- if (ex.getCause() instanceof HttpException) {
- throw (Exception) ex.getCause();
- } else {
- throw ex;
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2AlpnTest.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2AlpnTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2AlpnTest.java
new file mode 100644
index 0000000..20bb1c8
--- /dev/null
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http2AlpnTest.java
@@ -0,0 +1,241 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.core5.testing.nio;
+
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
+import org.apache.hc.core5.function.Supplier;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.Message;
+import org.apache.hc.core5.http.URIScheme;
+import org.apache.hc.core5.http.impl.bootstrap.HttpAsyncServer;
+import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
+import org.apache.hc.core5.http.nio.BasicRequestProducer;
+import org.apache.hc.core5.http.nio.BasicResponseConsumer;
+import org.apache.hc.core5.http.nio.entity.StringAsyncEntityConsumer;
+import org.apache.hc.core5.http.nio.entity.StringAsyncEntityProducer;
+import org.apache.hc.core5.http.nio.ssl.BasicServerTlsStrategy;
+import org.apache.hc.core5.http2.impl.nio.bootstrap.H2ServerBootstrap;
+import org.apache.hc.core5.http2.impl.nio.bootstrap.Http2MultiplexingRequester;
+import org.apache.hc.core5.http2.impl.nio.bootstrap.Http2MultiplexingRequesterBootstrap;
+import org.apache.hc.core5.http2.ssl.H2ClientTlsStrategy;
+import org.apache.hc.core5.io.CloseMode;
+import org.apache.hc.core5.reactor.ExceptionEvent;
+import org.apache.hc.core5.reactor.IOReactorConfig;
+import org.apache.hc.core5.reactor.ListenerEndpoint;
+import org.apache.hc.core5.testing.SSLTestContexts;
+import org.apache.hc.core5.testing.TestingSupport;
+import org.apache.hc.core5.util.Timeout;
+import org.hamcrest.CoreMatchers;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.rules.ExternalResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Http2AlpnTest {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ private static final Timeout TIMEOUT = Timeout.ofSeconds(30);
+
+ private HttpAsyncServer server;
+
+ @Rule
+ public ExternalResource serverResource = new ExternalResource() {
+
+ @Override
+ protected void before() throws Throwable {
+ log.debug("Starting up test server");
+ server = H2ServerBootstrap.bootstrap()
+ .setIOReactorConfig(
+ IOReactorConfig.custom()
+ .setSoTimeout(TIMEOUT)
+ .build())
+ .setTlsStrategy(new BasicServerTlsStrategy(
+ SSLTestContexts.createServerSSLContext(),
+ SecureAllPortsStrategy.INSTANCE))
+ .setIOSessionListener(LoggingIOSessionListener.INSTANCE)
+ .setIOSessionDecorator(LoggingIOSessionDecorator.INSTANCE)
+ .setStreamListener(LoggingHttp2StreamListener.INSTANCE)
+ .register("*", new Supplier<AsyncServerExchangeHandler>() {
+
+ @Override
+ public AsyncServerExchangeHandler get() {
+ return new EchoHandler(2048);
+ }
+
+ })
+ .create();
+ }
+
+ @Override
+ protected void after() {
+ log.debug("Shutting down test server");
+ if (server != null) {
+ try {
+ server.close(CloseMode.GRACEFUL);
+ final List<ExceptionEvent> exceptionLog = server.getExceptionLog();
+ server = null;
+ if (!exceptionLog.isEmpty()) {
+ for (final ExceptionEvent event: exceptionLog) {
+ final Throwable cause = event.getCause();
+ log.error("Unexpected " + cause.getClass() + " at " + event.getTimestamp(), cause);
+ }
+ }
+ } catch (final Exception ignore) {
+ }
+ }
+ }
+
+ };
+
+ private Http2MultiplexingRequester requester;
+
+ @Rule
+ public ExternalResource clientResource = new ExternalResource() {
+
+ @Override
+ protected void after() {
+ log.debug("Shutting down test client");
+ if (requester != null) {
+ try {
+ requester.close(CloseMode.GRACEFUL);
+ final List<ExceptionEvent> exceptionLog = requester.getExceptionLog();
+ requester = null;
+ if (!exceptionLog.isEmpty()) {
+ for (final ExceptionEvent event: exceptionLog) {
+ final Throwable cause = event.getCause();
+ log.error("Unexpected " + cause.getClass() + " at " + event.getTimestamp(), cause);
+ }
+ }
+ } catch (final Exception ignore) {
+ }
+ }
+ }
+
+ };
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private static int javaVersion;
+
+ @BeforeClass
+ public static void determineJavaVersion() {
+ javaVersion = TestingSupport.determineJRELevel();
+ }
+
+ @Before
+ public void checkVersion() {
+ Assume.assumeTrue("Java version must be 9 or greater", javaVersion >= 9);
+ }
+
+ @Test
+ public void testALPNLax() throws Exception {
+ log.debug("Starting up test client");
+ requester = Http2MultiplexingRequesterBootstrap.bootstrap()
+ .setIOReactorConfig(IOReactorConfig.custom()
+ .setSoTimeout(TIMEOUT)
+ .build())
+ .setTlsStrategy(new H2ClientTlsStrategy(SSLTestContexts.createClientSSLContext()))
+ .setStrictALPNHandshake(false)
+ .setIOSessionListener(LoggingIOSessionListener.INSTANCE)
+ .setIOSessionDecorator(LoggingIOSessionDecorator.INSTANCE)
+ .setStreamListener(LoggingHttp2StreamListener.INSTANCE)
+ .create();
+
+ server.start();
+ final Future<ListenerEndpoint> future = server.listen(new InetSocketAddress(0));
+ final ListenerEndpoint listener = future.get();
+ final InetSocketAddress address = (InetSocketAddress) listener.getAddress();
+ requester.start();
+
+ final HttpHost target = new HttpHost("localhost", address.getPort(), URIScheme.HTTPS.id);
+ final Future<Message<HttpResponse, String>> resultFuture1 = requester.execute(
+ new BasicRequestProducer("POST", target, "/stuff",
+ new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
+ new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
+ final Message<HttpResponse, String> message1 = resultFuture1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
+ Assert.assertThat(message1, CoreMatchers.notNullValue());
+ final HttpResponse response1 = message1.getHead();
+ Assert.assertThat(response1.getCode(), CoreMatchers.equalTo(HttpStatus.SC_OK));
+ final String body1 = message1.getBody();
+ Assert.assertThat(body1, CoreMatchers.equalTo("some stuff"));
+ }
+
+ @Test()
+ public void testALPNStrict() throws Exception {
+
+ thrown.expect(HttpException.class);
+ thrown.expectMessage("ALPN: missing application protocol");
+
+ log.debug("Starting up test client");
+ requester = Http2MultiplexingRequesterBootstrap.bootstrap()
+ .setIOReactorConfig(IOReactorConfig.custom()
+ .setSoTimeout(TIMEOUT)
+ .build())
+ .setTlsStrategy(new H2ClientTlsStrategy(SSLTestContexts.createClientSSLContext()))
+ .setStrictALPNHandshake(true)
+ .setIOSessionListener(LoggingIOSessionListener.INSTANCE)
+ .setIOSessionDecorator(LoggingIOSessionDecorator.INSTANCE)
+ .setStreamListener(LoggingHttp2StreamListener.INSTANCE)
+ .create();
+
+ server.start();
+ final Future<ListenerEndpoint> future = server.listen(new InetSocketAddress(0));
+ final ListenerEndpoint listener = future.get();
+ final InetSocketAddress address = (InetSocketAddress) listener.getAddress();
+ requester.start();
+
+ final HttpHost target = new HttpHost("localhost", address.getPort(), URIScheme.HTTPS.id);
+ final Future<Message<HttpResponse, String>> resultFuture1 = requester.execute(
+ new BasicRequestProducer("POST", target, "/stuff",
+ new StringAsyncEntityProducer("some stuff", ContentType.TEXT_PLAIN)),
+ new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), TIMEOUT, null);
+ try {
+ resultFuture1.get();
+ Assert.fail("ExecutionException expected");
+ } catch (final ExecutionException ex) {
+ throw ex.getCause() instanceof HttpException ? (Exception) ex.getCause() : ex;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TestDefaultListeningIOReactor.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TestDefaultListeningIOReactor.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TestDefaultListeningIOReactor.java
index 629847d..6c62641 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TestDefaultListeningIOReactor.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TestDefaultListeningIOReactor.java
@@ -52,7 +52,7 @@ import org.junit.Test;
*/
public class TestDefaultListeningIOReactor {
- private DefaultListeningIOReactor ioreactor;
+ private DefaultListeningIOReactor ioReactor;
private static class NoopIOEventHandlerFactory implements IOEventHandlerFactory {
@@ -92,38 +92,38 @@ public class TestDefaultListeningIOReactor {
final IOReactorConfig reactorConfig = IOReactorConfig.custom()
.setIoThreadCount(1)
.build();
- this.ioreactor = new DefaultListeningIOReactor(new NoopIOEventHandlerFactory(), reactorConfig, null);
+ this.ioReactor = new DefaultListeningIOReactor(new NoopIOEventHandlerFactory(), reactorConfig, null);
}
@After
public void cleanup() throws Exception {
- if (this.ioreactor != null) {
- this.ioreactor.close(CloseMode.IMMEDIATE);
+ if (this.ioReactor != null) {
+ this.ioReactor.close(CloseMode.IMMEDIATE);
}
}
@Test
public void testEndpointUpAndDown() throws Exception {
- ioreactor.start();
+ ioReactor.start();
- Set<ListenerEndpoint> endpoints = ioreactor.getEndpoints();
+ Set<ListenerEndpoint> endpoints = ioReactor.getEndpoints();
Assert.assertNotNull(endpoints);
Assert.assertEquals(0, endpoints.size());
- final Future<ListenerEndpoint> future1 = ioreactor.listen(new InetSocketAddress(0));
+ final Future<ListenerEndpoint> future1 = ioReactor.listen(new InetSocketAddress(0));
final ListenerEndpoint endpoint1 = future1.get();
- final Future<ListenerEndpoint> future2 = ioreactor.listen(new InetSocketAddress(0));
+ final Future<ListenerEndpoint> future2 = ioReactor.listen(new InetSocketAddress(0));
final ListenerEndpoint endpoint2 = future2.get();
final int port = ((InetSocketAddress) endpoint2.getAddress()).getPort();
- endpoints = ioreactor.getEndpoints();
+ endpoints = ioReactor.getEndpoints();
Assert.assertNotNull(endpoints);
Assert.assertEquals(2, endpoints.size());
endpoint1.close();
- endpoints = ioreactor.getEndpoints();
+ endpoints = ioReactor.getEndpoints();
Assert.assertNotNull(endpoints);
Assert.assertEquals(1, endpoints.size());
@@ -131,29 +131,29 @@ public class TestDefaultListeningIOReactor {
Assert.assertEquals(port, ((InetSocketAddress) endpoint.getAddress()).getPort());
- ioreactor.close(CloseMode.GRACEFUL);
- ioreactor.awaitShutdown(TimeValue.ofSeconds(5));
- Assert.assertEquals(IOReactorStatus.SHUT_DOWN, ioreactor.getStatus());
+ ioReactor.close(CloseMode.GRACEFUL);
+ ioReactor.awaitShutdown(TimeValue.ofSeconds(5));
+ Assert.assertEquals(IOReactorStatus.SHUT_DOWN, ioReactor.getStatus());
}
@Test
public void testEndpointAlreadyBound() throws Exception {
- ioreactor.start();
+ ioReactor.start();
- final Future<ListenerEndpoint> future1 = ioreactor.listen(new InetSocketAddress(0));
+ final Future<ListenerEndpoint> future1 = ioReactor.listen(new InetSocketAddress(0));
final ListenerEndpoint endpoint1 = future1.get();
final int port = ((InetSocketAddress) endpoint1.getAddress()).getPort();
- final Future<ListenerEndpoint> future2 = ioreactor.listen(new InetSocketAddress(port));
+ final Future<ListenerEndpoint> future2 = ioReactor.listen(new InetSocketAddress(port));
try {
future2.get();
Assert.fail("ExecutionException expected");
} catch (final ExecutionException expected) {
}
- ioreactor.close(CloseMode.GRACEFUL);
- ioreactor.awaitShutdown(TimeValue.ofSeconds(5));
+ ioReactor.close(CloseMode.GRACEFUL);
+ ioReactor.awaitShutdown(TimeValue.ofSeconds(5));
- Assert.assertEquals(IOReactorStatus.SHUT_DOWN, ioreactor.getStatus());
+ Assert.assertEquals(IOReactorStatus.SHUT_DOWN, ioReactor.getStatus());
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5/src/main/java/org/apache/hc/core5/http/ConnectionRequestTimeoutException.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/ConnectionRequestTimeoutException.java b/httpcore5/src/main/java/org/apache/hc/core5/http/ConnectionRequestTimeoutException.java
index 5847433..d6d2dfc 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/ConnectionRequestTimeoutException.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/ConnectionRequestTimeoutException.java
@@ -36,6 +36,8 @@ import java.io.InterruptedIOException;
*/
public class ConnectionRequestTimeoutException extends InterruptedIOException {
+ private static final long serialVersionUID = 1L;
+
/**
* Creates a {@link ConnectionRequestTimeoutException} without details.
*/
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5/src/main/java/org/apache/hc/core5/http/MethodNotSupportedException.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/MethodNotSupportedException.java b/httpcore5/src/main/java/org/apache/hc/core5/http/MethodNotSupportedException.java
index b32b0be..9a3c0c5 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/MethodNotSupportedException.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/MethodNotSupportedException.java
@@ -34,6 +34,8 @@ package org.apache.hc.core5.http;
*/
public class MethodNotSupportedException extends ProtocolException {
+ private static final long serialVersionUID = 1L;
+
/**
* Creates a new MethodNotSupportedException with the specified detail message.
*
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5/src/main/java/org/apache/hc/core5/http/MisdirectedRequestException.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/MisdirectedRequestException.java b/httpcore5/src/main/java/org/apache/hc/core5/http/MisdirectedRequestException.java
index ee229a9..2d80914 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/MisdirectedRequestException.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/MisdirectedRequestException.java
@@ -34,6 +34,8 @@ package org.apache.hc.core5.http;
*/
public class MisdirectedRequestException extends ProtocolException {
+ private static final long serialVersionUID = 1L;
+
/**
* Creates an exception without a detail message.
*/
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java b/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java
index abf2406..c7d898e 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/StreamClosedException.java
@@ -36,6 +36,8 @@ import java.io.IOException;
*/
public class StreamClosedException extends IOException {
+ private static final long serialVersionUID = 1L;
+
public StreamClosedException() {
super("Stream already closed");
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
index 40c639a..9ef054a 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
@@ -76,17 +76,17 @@ class BHttpConnectionBase implements BHttpConnection {
BHttpConnectionBase(
final H1Config h1Config,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder) {
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder) {
this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
final BasicHttpTransportMetrics inTransportMetrics = new BasicHttpTransportMetrics();
final BasicHttpTransportMetrics outTransportMetrics = new BasicHttpTransportMetrics();
this.inBuffer = new SessionInputBufferImpl(inTransportMetrics,
this.h1Config.getBufferSize(), -1,
- this.h1Config.getMaxLineLength(), chardecoder);
+ this.h1Config.getMaxLineLength(), charDecoder);
this.outbuffer = new SessionOutputBufferImpl(outTransportMetrics,
this.h1Config.getBufferSize(),
- this.h1Config.getChunkSizeHint(), charencoder);
+ this.h1Config.getChunkSizeHint(), charEncoder);
this.connMetrics = new BasicHttpConnectionMetrics(inTransportMetrics, outTransportMetrics);
this.socketHolderRef = new AtomicReference<>();
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
index 841d48f..87a381f 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
@@ -72,9 +72,9 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
*
* @param h1Config Message h1Config. If {@code null}
* {@link H1Config#DEFAULT} will be used.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @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.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder encoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param incomingContentStrategy incoming content length strategy. If {@code null}
* {@link DefaultContentLengthStrategy#INSTANCE} will be used.
@@ -87,13 +87,13 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
*/
public DefaultBHttpClientConnection(
final H1Config h1Config,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
- super(h1Config, chardecoder, charencoder);
+ super(h1Config, charDecoder, charEncoder);
this.requestWriter = (requestWriterFactory != null ? requestWriterFactory :
DefaultHttpRequestWriterFactory.INSTANCE).create();
this.responseParser = (responseParserFactory != null ? responseParserFactory :
@@ -107,9 +107,9 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
public DefaultBHttpClientConnection(
final H1Config h1Config,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder) {
- this(h1Config, chardecoder, charencoder, null, null, null, null);
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder) {
+ this(h1Config, charDecoder, charEncoder, null, null, null, null);
}
public DefaultBHttpClientConnection(final H1Config h1Config) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java
index 3bde5f1..119a538 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java
@@ -70,9 +70,9 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
* @param scheme protocol scheme
* @param h1Config Message h1Config. If {@code null}
* {@link H1Config#DEFAULT} will be used.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @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.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder encoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param incomingContentStrategy incoming content length strategy. If {@code null}
* {@link DefaultContentLengthStrategy#INSTANCE} will be used.
@@ -86,13 +86,13 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
public DefaultBHttpServerConnection(
final String scheme,
final H1Config h1Config,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageParserFactory<ClassicHttpRequest> requestParserFactory,
final HttpMessageWriterFactory<ClassicHttpResponse> responseWriterFactory) {
- super(h1Config, chardecoder, charencoder);
+ super(h1Config, charDecoder, charEncoder);
this.scheme = scheme;
this.requestParser = (requestParserFactory != null ? requestParserFactory :
DefaultHttpRequestParserFactory.INSTANCE).create(h1Config);
@@ -107,9 +107,9 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
public DefaultBHttpServerConnection(
final String scheme,
final H1Config h1Config,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder) {
- this(scheme, h1Config, chardecoder, charencoder, null, null, null, null);
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder) {
+ this(scheme, h1Config, charDecoder, charEncoder, null, null, null, null);
}
public DefaultBHttpServerConnection(
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java
index 245a1b2..8ed9beb 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java
@@ -78,7 +78,7 @@ public class SessionInputBufferImpl implements SessionInputBuffer {
* between performance of memory copy operations and that of native method invocation.
* If negative default chunk limited will be used.
* @param maxLineLen maximum line length.
- * @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(
@@ -86,7 +86,7 @@ public class SessionInputBufferImpl implements SessionInputBuffer {
final int bufferSize,
final int minChunkLimit,
final int maxLineLen,
- final CharsetDecoder chardecoder) {
+ final CharsetDecoder charDecoder) {
Args.notNull(metrics, "HTTP transport metrcis");
Args.positive(bufferSize, "Buffer size");
this.metrics = metrics;
@@ -96,7 +96,7 @@ public class SessionInputBufferImpl implements SessionInputBuffer {
this.minChunkLimit = minChunkLimit >= 0 ? minChunkLimit : 512;
this.maxLineLen = maxLineLen > 0 ? maxLineLen : 0;
this.lineBuffer = new ByteArrayBuffer(bufferSize);
- this.decoder = chardecoder;
+ this.decoder = charDecoder;
}
public SessionInputBufferImpl(
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionOutputBufferImpl.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionOutputBufferImpl.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionOutputBufferImpl.java
index cb30398..7960499 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionOutputBufferImpl.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionOutputBufferImpl.java
@@ -71,21 +71,21 @@ public class SessionOutputBufferImpl implements SessionOutputBuffer {
* @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.
- * @param charencoder charencoder to be used for encoding HTTP protocol elements.
+ * @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.
*/
public SessionOutputBufferImpl(
final BasicHttpTransportMetrics metrics,
final int bufferSize,
final int fragementSizeHint,
- final CharsetEncoder charencoder) {
+ final CharsetEncoder charEncoder) {
super();
Args.positive(bufferSize, "Buffer size");
Args.notNull(metrics, "HTTP transport metrcis");
this.metrics = metrics;
this.buffer = new ByteArrayBuffer(bufferSize);
this.fragementSizeHint = fragementSizeHint >= 0 ? fragementSizeHint : bufferSize;
- this.encoder = charencoder;
+ this.encoder = charEncoder;
}
public SessionOutputBufferImpl(final int bufferSize) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionInputBufferImpl.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionInputBufferImpl.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionInputBufferImpl.java
index f5e4e5a..d5a0948 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionInputBufferImpl.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionInputBufferImpl.java
@@ -50,7 +50,7 @@ import org.apache.hc.core5.util.CharArrayBuffer;
*/
public class SessionInputBufferImpl extends ExpandableBuffer implements SessionInputBuffer {
- private final CharsetDecoder chardecoder;
+ private final CharsetDecoder charDecoder;
private final int lineBuffersize;
private final int maxLineLen;
@@ -61,8 +61,8 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
*
* @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.
+ * {@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 maxLineLen maximum line length.
*
@@ -72,11 +72,11 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
final int bufferSize,
final int lineBuffersize,
final int maxLineLen,
- final CharsetDecoder chardecoder) {
+ final CharsetDecoder charDecoder) {
super(bufferSize);
this.lineBuffersize = Args.positive(lineBuffersize, "Line buffer size");
this.maxLineLen = maxLineLen > 0 ? maxLineLen : 0;
- this.chardecoder = chardecoder;
+ this.charDecoder = charDecoder;
}
/**
@@ -236,7 +236,7 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
// Ensure capacity of len assuming ASCII as the most likely charset
lineBuffer.ensureCapacity(requiredCapacity);
- if (this.chardecoder == null) {
+ if (this.charDecoder == null) {
if (buffer().hasArray()) {
final byte[] b = buffer().array();
final int off = buffer().position();
@@ -252,10 +252,10 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
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(
buffer(),
this.charbuffer,
true);
@@ -276,7 +276,7 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
}
// flush the decoder
- this.chardecoder.flush(this.charbuffer);
+ this.charDecoder.flush(this.charbuffer);
this.charbuffer.flip();
// append the decoded content to the line buffer
if (this.charbuffer.hasRemaining()) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionOutputBufferImpl.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionOutputBufferImpl.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionOutputBufferImpl.java
index f631910..163bad3 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionOutputBufferImpl.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionOutputBufferImpl.java
@@ -52,7 +52,7 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
private static final byte[] CRLF = new byte[] {Chars.CR, Chars.LF};
- private final CharsetEncoder charencoder;
+ private final CharsetEncoder charEncoder;
private final int lineBuffersize;
private CharBuffer charbuffer;
@@ -62,8 +62,8 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
*
* @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.
+ * {@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.
*
* @since 4.3
@@ -71,10 +71,10 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
public SessionOutputBufferImpl(
final int bufferSize,
final int lineBuffersize,
- final CharsetEncoder charencoder) {
+ final CharsetEncoder charEncoder) {
super(bufferSize);
this.lineBuffersize = Args.positive(lineBuffersize, "Line buffer size");
- this.charencoder = charencoder;
+ this.charEncoder = charEncoder;
}
/**
@@ -154,7 +154,7 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
setInputMode();
// Do not bother if the buffer is empty
if (lineBuffer.length() > 0 ) {
- if (this.charencoder == null) {
+ if (this.charEncoder == null) {
final int requiredCapacity = buffer().position() + lineBuffer.length();
ensureCapacity(requiredCapacity);
if (buffer().hasArray()) {
@@ -174,7 +174,7 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
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 offset = 0;
@@ -191,7 +191,7 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
boolean retry = true;
while (retry) {
- final CoderResult result = this.charencoder.encode(this.charbuffer, buffer(), eol);
+ final CoderResult result = this.charEncoder.encode(this.charbuffer, buffer(), eol);
if (result.isError()) {
result.throwException();
}
@@ -207,7 +207,7 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
// flush the encoder
boolean retry = true;
while (retry) {
- final CoderResult result = this.charencoder.flush(buffer());
+ final CoderResult result = this.charEncoder.flush(buffer());
if (result.isError()) {
result.throwException();
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicClassicHttpResponse.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicClassicHttpResponse.java b/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicClassicHttpResponse.java
index 4d20702..ddd42d0 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicClassicHttpResponse.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicClassicHttpResponse.java
@@ -41,6 +41,7 @@ import org.apache.hc.core5.http.ReasonPhraseCatalog;
*/
public class BasicClassicHttpResponse extends BasicHttpResponse implements ClassicHttpResponse {
+ private static final long serialVersionUID = 1L;
private HttpEntity entity;
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5/src/main/java/org/apache/hc/core5/net/Host.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/net/Host.java b/httpcore5/src/main/java/org/apache/hc/core5/net/Host.java
index 9f8b2b7..53afecd 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/net/Host.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/net/Host.java
@@ -39,6 +39,7 @@ import org.apache.hc.core5.util.TextUtils;
@Contract(threading = ThreadingBehavior.IMMUTABLE)
public final class Host implements NamedEndpoint, Serializable {
+ private static final long serialVersionUID = 1L;
private final String name;
private final String lcName;
private final int port;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java b/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java
index 9484100..b1aaacf 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java
@@ -45,6 +45,7 @@ import org.apache.hc.core5.util.TextUtils;
@Contract(threading = ThreadingBehavior.IMMUTABLE)
public final class URIAuthority implements NamedEndpoint, Serializable {
+ private static final long serialVersionUID = 1L;
private final String userInfo;
private final String hostname;
private final int port;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorShutdownException.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorShutdownException.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorShutdownException.java
index 3e3854e..b7bb5c9 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorShutdownException.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorShutdownException.java
@@ -34,6 +34,8 @@ package org.apache.hc.core5.reactor;
*/
public class IOReactorShutdownException extends IllegalStateException {
+ private static final long serialVersionUID = 1L;
+
public IOReactorShutdownException(final String message) {
super(message);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc6be3e6/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLManagedBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLManagedBuffer.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLManagedBuffer.java
index 138e1e8..4c1d2b6 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLManagedBuffer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLManagedBuffer.java
@@ -58,11 +58,7 @@ abstract class SSLManagedBuffer {
abstract boolean hasData();
static SSLManagedBuffer create(final SSLBufferMode mode, final int size) {
- if (mode == SSLBufferMode.DYNAMIC) {
- return new DynamicBuffer(size);
- } else {
- return new StaticBuffer(size);
- }
+ return mode == SSLBufferMode.DYNAMIC ? new DynamicBuffer(size) : new StaticBuffer(size);
}
static final class StaticBuffer extends SSLManagedBuffer {