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 18:50:41 UTC
[2/4] httpcomponents-core git commit: - Always use blocks - Add
missing serial version ID (default 1L) - Camel-case names. - Don't nest in
else clause unnecessarily. - Remove declared exceptions that are not thrown
(but don't break BC.)
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java b/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
index d1b1953..9672db6 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
@@ -103,15 +103,15 @@ public class TestNIOConnPool {
static class LocalSessionPool extends AbstractNIOConnPool<String, IOSession, LocalPoolEntry> {
public LocalSessionPool(
- final ConnectingIOReactor ioreactor, final int defaultMaxPerRoute, final int maxTotal) {
- super(ioreactor, new LocalConnFactory(), new LocalAddressResolver(), defaultMaxPerRoute, maxTotal);
+ final ConnectingIOReactor ioReactor, final int defaultMaxPerRoute, final int maxTotal) {
+ super(ioReactor, new LocalConnFactory(), new LocalAddressResolver(), defaultMaxPerRoute, maxTotal);
}
public LocalSessionPool(
- final ConnectingIOReactor ioreactor,
+ final ConnectingIOReactor ioReactor,
final SocketAddressResolver<String> addressResolver,
final int defaultMaxPerRoute, final int maxTotal) {
- super(ioreactor, new LocalConnFactory(), addressResolver, defaultMaxPerRoute, maxTotal);
+ super(ioReactor, new LocalConnFactory(), addressResolver, defaultMaxPerRoute, maxTotal);
}
@Override
@@ -123,8 +123,8 @@ public class TestNIOConnPool {
@Test
public void testEmptyPool() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
final PoolStats totals = pool.getTotalStats();
Assert.assertEquals(0, totals.getAvailable());
Assert.assertEquals(0, totals.getLeased());
@@ -149,19 +149,19 @@ public class TestNIOConnPool {
@Test
public void testInvalidConstruction() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
try {
new LocalSessionPool(null, 1, 1);
Assert.fail("IllegalArgumentException should have been thrown");
} catch (final IllegalArgumentException expected) {
}
try {
- new LocalSessionPool(ioreactor, -1, 1);
+ new LocalSessionPool(ioReactor, -1, 1);
Assert.fail("IllegalArgumentException should have been thrown");
} catch (final IllegalArgumentException expected) {
}
try {
- new LocalSessionPool(ioreactor, 1, -1);
+ new LocalSessionPool(ioReactor, 1, -1);
Assert.fail("IllegalArgumentException should have been thrown");
} catch (final IllegalArgumentException expected) {
}
@@ -169,17 +169,17 @@ public class TestNIOConnPool {
@Test
public void testSuccessfulConnect() throws Exception {
- final IOSession iosession = Mockito.mock(IOSession.class);
+ final IOSession ioSession = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest.getSession()).thenReturn(iosession);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ Mockito.when(sessionRequest.getSession()).thenReturn(ioSession);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
final Future<LocalPoolEntry> future = pool.lease("somehost", null, 100, TimeUnit.MILLISECONDS, null);
Mockito.verify(sessionRequest).setConnectTimeout(100);
@@ -206,13 +206,13 @@ public class TestNIOConnPool {
final SessionRequest sessionRequest = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest.getAttachment()).thenReturn("somehost");
Mockito.when(sessionRequest.getException()).thenReturn(new IOException());
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
final Future<LocalPoolEntry> future = pool.lease("somehost", null);
PoolStats totals = pool.getTotalStats();
@@ -239,18 +239,18 @@ public class TestNIOConnPool {
@Test
public void testCencelledConnect() throws Exception {
- final IOSession iosession = Mockito.mock(IOSession.class);
+ final IOSession ioSession = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest.getSession()).thenReturn(iosession);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ Mockito.when(sessionRequest.getSession()).thenReturn(ioSession);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest);
- Mockito.when(ioreactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ Mockito.when(ioReactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
final Future<LocalPoolEntry> future = pool.lease("somehost", null);
PoolStats totals = pool.getTotalStats();
@@ -276,19 +276,19 @@ public class TestNIOConnPool {
@Test
public void testTimeoutConnect() throws Exception {
- final IOSession iosession = Mockito.mock(IOSession.class);
+ final IOSession ioSession = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest.getAttachment()).thenReturn("somehost");
Mockito.when(sessionRequest.getRemoteAddress())
.thenReturn(new InetSocketAddress(InetAddress.getByAddress(new byte[]{127, 0, 0, 1}), 80));
- Mockito.when(sessionRequest.getSession()).thenReturn(iosession);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ Mockito.when(sessionRequest.getSession()).thenReturn(ioSession);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
final Future<LocalPoolEntry> future = pool.lease("somehost", null);
PoolStats totals = pool.getTotalStats();
@@ -319,10 +319,10 @@ public class TestNIOConnPool {
final SessionRequest sessionRequest = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest.getAttachment()).thenReturn("somehost");
Mockito.when(sessionRequest.getException()).thenReturn(new IOException());
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
final SocketAddressResolver<String> addressResolver = Mockito.mock(SocketAddressResolver.class);
Mockito.when(addressResolver.resolveRemoteAddress("somehost")).thenThrow(new UnknownHostException());
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, addressResolver, 2, 10);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, addressResolver, 2, 10);
final Future<LocalPoolEntry> future = pool.lease("somehost", null);
Assert.assertTrue(future.isDone());
@@ -337,29 +337,29 @@ public class TestNIOConnPool {
@Test
public void testLeaseRelease() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final IOSession iosession2 = Mockito.mock(IOSession.class);
+ final IOSession ioSession2 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest2 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest2.getAttachment()).thenReturn("otherhost");
- Mockito.when(sessionRequest2.getSession()).thenReturn(iosession2);
+ Mockito.when(sessionRequest2.getSession()).thenReturn(ioSession2);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1);
- Mockito.when(ioreactor.connect(
+ Mockito.when(ioReactor.connect(
Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest2);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
pool.requestCompleted(sessionRequest1);
final Future<LocalPoolEntry> future2 = pool.lease("somehost", null);
@@ -377,8 +377,8 @@ public class TestNIOConnPool {
pool.release(entry1, true);
pool.release(entry2, true);
pool.release(entry3, false);
- Mockito.verify(iosession1, Mockito.never()).close();
- Mockito.verify(iosession2, Mockito.times(1)).close();
+ Mockito.verify(ioSession1, Mockito.never()).close();
+ Mockito.verify(ioSession2, Mockito.times(1)).close();
final PoolStats totals = pool.getTotalStats();
Assert.assertEquals(2, totals.getAvailable());
@@ -388,8 +388,8 @@ public class TestNIOConnPool {
@Test
public void testLeaseIllegal() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
try {
pool.lease(null, null, 0, TimeUnit.MILLISECONDS, null);
Assert.fail("IllegalArgumentException should have been thrown");
@@ -404,36 +404,36 @@ public class TestNIOConnPool {
@Test
public void testReleaseUnknownEntry() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
pool.release(new LocalPoolEntry("somehost", Mockito.mock(IOSession.class)), true);
}
@Test
public void testMaxLimits() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final IOSession iosession2 = Mockito.mock(IOSession.class);
+ final IOSession ioSession2 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest2 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest2.getAttachment()).thenReturn("otherhost");
- Mockito.when(sessionRequest2.getSession()).thenReturn(iosession2);
+ Mockito.when(sessionRequest2.getSession()).thenReturn(ioSession2);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1);
- Mockito.when(ioreactor.connect(
+ Mockito.when(ioReactor.connect(
Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest2);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
pool.setMaxPerRoute("somehost", 2);
pool.setMaxPerRoute("otherhost", 1);
pool.setMaxTotal(3);
@@ -481,7 +481,7 @@ public class TestNIOConnPool {
Assert.assertFalse(future8.isDone());
Assert.assertFalse(future9.isDone());
- Mockito.verify(ioreactor, Mockito.times(3)).connect(
+ Mockito.verify(ioReactor, Mockito.times(3)).connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -493,46 +493,46 @@ public class TestNIOConnPool {
Assert.assertFalse(future8.isDone());
Assert.assertTrue(future9.isDone());
- Mockito.verify(ioreactor, Mockito.times(4)).connect(
+ Mockito.verify(ioReactor, Mockito.times(4)).connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
}
@Test
public void testConnectionRedistributionOnTotalMaxLimit() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final IOSession iosession2 = Mockito.mock(IOSession.class);
+ final IOSession ioSession2 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest2 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest2.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest2.getSession()).thenReturn(iosession2);
+ Mockito.when(sessionRequest2.getSession()).thenReturn(ioSession2);
- final IOSession iosession3 = Mockito.mock(IOSession.class);
+ final IOSession ioSession3 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest3 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest3.getAttachment()).thenReturn("otherhost");
- Mockito.when(sessionRequest3.getSession()).thenReturn(iosession3);
+ Mockito.when(sessionRequest3.getSession()).thenReturn(ioSession3);
- final IOSession iosession4 = Mockito.mock(IOSession.class);
+ final IOSession ioSession4 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest4 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest4.getAttachment()).thenReturn("otherhost");
- Mockito.when(sessionRequest4.getSession()).thenReturn(iosession4);
+ Mockito.when(sessionRequest4.getSession()).thenReturn(ioSession4);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1, sessionRequest2, sessionRequest1);
- Mockito.when(ioreactor.connect(
+ Mockito.when(ioReactor.connect(
Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest3, sessionRequest4, sessionRequest3);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
pool.setMaxPerRoute("somehost", 2);
pool.setMaxPerRoute("otherhost", 2);
pool.setMaxTotal(2);
@@ -542,12 +542,12 @@ public class TestNIOConnPool {
final Future<LocalPoolEntry> future3 = pool.lease("otherhost", null);
final Future<LocalPoolEntry> future4 = pool.lease("otherhost", null);
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
- Mockito.verify(ioreactor, Mockito.never()).connect(
+ Mockito.verify(ioReactor, Mockito.never()).connect(
Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -573,12 +573,12 @@ public class TestNIOConnPool {
pool.release(entry1, true);
pool.release(entry2, true);
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -601,12 +601,12 @@ public class TestNIOConnPool {
final Future<LocalPoolEntry> future5 = pool.lease("somehost", null);
final Future<LocalPoolEntry> future6 = pool.lease("otherhost", null);
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -614,12 +614,12 @@ public class TestNIOConnPool {
pool.release(entry3, true);
pool.release(entry4, true);
- Mockito.verify(ioreactor, Mockito.times(3)).connect(
+ Mockito.verify(ioReactor, Mockito.times(3)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -641,12 +641,12 @@ public class TestNIOConnPool {
pool.release(entry5, true);
pool.release(entry6, true);
- Mockito.verify(ioreactor, Mockito.times(3)).connect(
+ Mockito.verify(ioReactor, Mockito.times(3)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -659,36 +659,36 @@ public class TestNIOConnPool {
@Test
public void testStatefulConnectionRedistributionOnPerRouteMaxLimit() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final IOSession iosession2 = Mockito.mock(IOSession.class);
+ final IOSession ioSession2 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest2 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest2.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest2.getSession()).thenReturn(iosession2);
+ Mockito.when(sessionRequest2.getSession()).thenReturn(ioSession2);
- final IOSession iosession3 = Mockito.mock(IOSession.class);
+ final IOSession ioSession3 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest3 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest3.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest3.getSession()).thenReturn(iosession3);
+ Mockito.when(sessionRequest3.getSession()).thenReturn(ioSession3);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1, sessionRequest2, sessionRequest3);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
pool.setMaxPerRoute("somehost", 2);
pool.setMaxTotal(2);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
final Future<LocalPoolEntry> future2 = pool.lease("somehost", null);
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -723,7 +723,7 @@ public class TestNIOConnPool {
final LocalPoolEntry entry4 = future4.get();
Assert.assertNotNull(entry4);
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -740,13 +740,13 @@ public class TestNIOConnPool {
Assert.assertFalse(future5.isDone());
- Mockito.verify(ioreactor, Mockito.times(3)).connect(
+ Mockito.verify(ioReactor, Mockito.times(3)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
- Mockito.verify(iosession2).close();
- Mockito.verify(iosession1, Mockito.never()).close();
+ Mockito.verify(ioSession2).close();
+ Mockito.verify(ioSession1, Mockito.never()).close();
totals = pool.getTotalStats();
Assert.assertEquals(1, totals.getAvailable());
@@ -756,24 +756,24 @@ public class TestNIOConnPool {
@Test
public void testCreateNewIfExpired() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
- Mockito.when(iosession1.isClosed()).thenReturn(Boolean.TRUE);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
+ Mockito.when(ioSession1.isClosed()).thenReturn(Boolean.TRUE);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
- Mockito.verify(ioreactor, Mockito.times(1)).connect(
+ Mockito.verify(ioReactor, Mockito.times(1)).connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -792,8 +792,8 @@ public class TestNIOConnPool {
Assert.assertFalse(future2.isDone());
- Mockito.verify(iosession1).close();
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioSession1).close();
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -810,24 +810,24 @@ public class TestNIOConnPool {
@Test
public void testCloseExpired() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
- Mockito.when(iosession1.isClosed()).thenReturn(Boolean.TRUE);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
+ Mockito.when(ioSession1.isClosed()).thenReturn(Boolean.TRUE);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final IOSession iosession2 = Mockito.mock(IOSession.class);
+ final IOSession ioSession2 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest2 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest2.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest2.getSession()).thenReturn(iosession2);
+ Mockito.when(sessionRequest2.getSession()).thenReturn(ioSession2);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1, sessionRequest2);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
final Future<LocalPoolEntry> future2 = pool.lease("somehost", null);
@@ -852,8 +852,8 @@ public class TestNIOConnPool {
pool.closeExpired();
- Mockito.verify(iosession1).close();
- Mockito.verify(iosession2, Mockito.never()).close();
+ Mockito.verify(ioSession1).close();
+ Mockito.verify(ioSession2, Mockito.never()).close();
final PoolStats totals = pool.getTotalStats();
Assert.assertEquals(1, totals.getAvailable());
@@ -867,23 +867,23 @@ public class TestNIOConnPool {
@Test
public void testCloseIdle() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final IOSession iosession2 = Mockito.mock(IOSession.class);
+ final IOSession ioSession2 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest2 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest2.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest2.getSession()).thenReturn(iosession2);
+ Mockito.when(sessionRequest2.getSession()).thenReturn(ioSession2);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1, sessionRequest2);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
final Future<LocalPoolEntry> future2 = pool.lease("somehost", null);
@@ -908,8 +908,8 @@ public class TestNIOConnPool {
pool.closeIdle(50, TimeUnit.MILLISECONDS);
- Mockito.verify(iosession1).close();
- Mockito.verify(iosession2, Mockito.never()).close();
+ Mockito.verify(ioSession1).close();
+ Mockito.verify(ioSession2, Mockito.never()).close();
PoolStats totals = pool.getTotalStats();
Assert.assertEquals(1, totals.getAvailable());
@@ -922,7 +922,7 @@ public class TestNIOConnPool {
pool.closeIdle(-1, TimeUnit.MILLISECONDS);
- Mockito.verify(iosession2).close();
+ Mockito.verify(ioSession2).close();
totals = pool.getTotalStats();
Assert.assertEquals(0, totals.getAvailable());
@@ -936,19 +936,19 @@ public class TestNIOConnPool {
@Test
public void testLeaseRequestTimeout() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
- Mockito.when(iosession1.isClosed()).thenReturn(Boolean.TRUE);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
+ Mockito.when(ioSession1.isClosed()).thenReturn(Boolean.TRUE);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 1, 1);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 1, 1);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null, 0, TimeUnit.MILLISECONDS, null);
final Future<LocalPoolEntry> future2 = pool.lease("somehost", null, 0, TimeUnit.MILLISECONDS, null);
@@ -972,22 +972,22 @@ public class TestNIOConnPool {
@Test(expected=IllegalArgumentException.class)
public void testCloseIdleInvalid() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
pool.closeIdle(50, null);
}
@Test(expected=IllegalArgumentException.class)
public void testGetStatsInvalid() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
pool.getStats(null);
}
@Test
public void testSetMaxInvalid() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
try {
pool.setMaxTotal(-1);
Assert.fail("IllegalArgumentException should have been thrown");
@@ -1007,8 +1007,8 @@ public class TestNIOConnPool {
@Test
public void testSetMaxPerRoute() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
pool.setMaxPerRoute("somehost", 1);
Assert.assertEquals(1, pool.getMaxPerRoute("somehost"));
pool.setMaxPerRoute("somehost", 0);
@@ -1019,12 +1019,12 @@ public class TestNIOConnPool {
@Test
public void testShutdown() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
pool.shutdown(1000);
- Mockito.verify(ioreactor, Mockito.times(1)).shutdown(1000);
+ Mockito.verify(ioReactor, Mockito.times(1)).shutdown(1000);
pool.shutdown(1000);
- Mockito.verify(ioreactor, Mockito.times(1)).shutdown(1000);
+ Mockito.verify(ioReactor, Mockito.times(1)).shutdown(1000);
try {
pool.lease("somehost", null);
Assert.fail("IllegalStateException should have been thrown");
@@ -1040,20 +1040,20 @@ public class TestNIOConnPool {
@Test
public void testLeaseRequestCanceled() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
- Mockito.when(iosession1.isClosed()).thenReturn(Boolean.TRUE);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
+ Mockito.when(ioSession1.isClosed()).thenReturn(Boolean.TRUE);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1);
- Mockito.when(ioreactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
+ Mockito.when(ioReactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 1, 1);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 1, 1);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null, 0, TimeUnit.MILLISECONDS, null);
future1.cancel(true);
@@ -1074,20 +1074,20 @@ public class TestNIOConnPool {
@Test
public void testLeaseRequestCanceledWhileConnecting() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
- Mockito.when(iosession1.isClosed()).thenReturn(Boolean.TRUE);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
+ Mockito.when(ioSession1.isClosed()).thenReturn(Boolean.TRUE);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1);
- Mockito.when(ioreactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
+ Mockito.when(ioReactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 1, 1);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 1, 1);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null, 0, TimeUnit.MILLISECONDS, null);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncRequestConsumer.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncRequestConsumer.java b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncRequestConsumer.java
index 2d2bd68..af496ae 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncRequestConsumer.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncRequestConsumer.java
@@ -50,7 +50,7 @@ public class TestBasicAsyncRequestConsumer {
@Mock private HttpEntityEnclosingRequest request;
@Mock private HttpContext context;
@Mock private ContentDecoder decoder;
- @Mock private IOControl ioctrl;
+ @Mock private IOControl ioControl;
@Before
public void setUp() throws Exception {
@@ -68,7 +68,7 @@ public class TestBasicAsyncRequestConsumer {
when(request.getEntity()).thenReturn(new StringEntity("stuff"));
consumer.requestReceived(request);
- consumer.consumeContent(decoder, ioctrl);
+ consumer.consumeContent(decoder, ioControl);
consumer.requestCompleted(context);
verify(consumer).releaseResources();
@@ -88,7 +88,7 @@ public class TestBasicAsyncRequestConsumer {
when(consumer.buildResult(context)).thenThrow(ooopsie);
consumer.requestReceived(request);
- consumer.consumeContent(decoder, ioctrl);
+ consumer.consumeContent(decoder, ioControl);
consumer.requestCompleted(context);
verify(consumer).releaseResources();
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncResponseConsumer.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncResponseConsumer.java b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncResponseConsumer.java
index 959dd20..e52c4fa 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncResponseConsumer.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBasicAsyncResponseConsumer.java
@@ -50,7 +50,7 @@ public class TestBasicAsyncResponseConsumer {
@Mock private HttpResponse response;
@Mock private HttpContext context;
@Mock private ContentDecoder decoder;
- @Mock private IOControl ioctrl;
+ @Mock private IOControl ioControl;
@Before
public void setUp() throws Exception {
@@ -68,7 +68,7 @@ public class TestBasicAsyncResponseConsumer {
when(response.getEntity()).thenReturn(new StringEntity("stuff"));
consumer.responseReceived(response);
- consumer.consumeContent(decoder, ioctrl);
+ consumer.consumeContent(decoder, ioControl);
consumer.responseCompleted(context);
verify(consumer).releaseResources();
@@ -88,7 +88,7 @@ public class TestBasicAsyncResponseConsumer {
when(consumer.buildResult(context)).thenThrow(ooopsie);
consumer.responseReceived(response);
- consumer.consumeContent(decoder, ioctrl);
+ consumer.consumeContent(decoder, ioControl);
consumer.responseCompleted(context);
verify(consumer).releaseResources();
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ClientConnectionFactory.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ClientConnectionFactory.java b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ClientConnectionFactory.java
index 0042772..b6121b6 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ClientConnectionFactory.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ClientConnectionFactory.java
@@ -56,14 +56,14 @@ public class ClientConnectionFactory implements NHttpConnectionFactory<DefaultNH
}
@Override
- public DefaultNHttpClientConnection createConnection(final IOSession iosession) {
+ public DefaultNHttpClientConnection createConnection(final IOSession ioSession) {
if (this.sslContext != null) {
- final SSLIOSession ssliosession = new SSLIOSession(
- iosession, SSLMode.CLIENT, this.sslContext, this.setupHandler);
- iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession);
- return new LoggingNHttpClientConnection(ssliosession);
+ final SSLIOSession sslioSession = new SSLIOSession(
+ ioSession, SSLMode.CLIENT, this.sslContext, this.setupHandler);
+ ioSession.setAttribute(SSLIOSession.SESSION_KEY, sslioSession);
+ return new LoggingNHttpClientConnection(sslioSession);
} else {
- return new LoggingNHttpClientConnection(iosession);
+ return new LoggingNHttpClientConnection(ioSession);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingIOSession.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingIOSession.java b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingIOSession.java
index 4aa4c03..b898b7a 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingIOSession.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingIOSession.java
@@ -45,18 +45,18 @@ import org.apache.http.nio.reactor.SessionBufferStatus;
public class LoggingIOSession implements IOSession {
private final Log log;
- private final Wire wirelog;
+ private final Wire wireLog;
private final String id;
private final IOSession session;
private final ByteChannel channel;
- public LoggingIOSession(final IOSession session, final String id, final Log log, final Log wirelog) {
+ public LoggingIOSession(final IOSession session, final String id, final Log log, final Log wireLog) {
super();
this.session = session;
this.channel = new LoggingByteChannel();
this.id = id;
this.log = log;
- this.wirelog = new Wire(wirelog, this.id);
+ this.wireLog = new Wire(wireLog, this.id);
}
@Override
@@ -210,12 +210,12 @@ public class LoggingIOSession implements IOSession {
if (log.isDebugEnabled()) {
log.debug(id + " " + 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;
}
@@ -226,12 +226,12 @@ public class LoggingIOSession implements IOSession {
if (log.isDebugEnabled()) {
log.debug(id + " " + 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/07a4acf7/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpClientConnection.java b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpClientConnection.java
index 60dbb57..4428e29 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpClientConnection.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpClientConnection.java
@@ -46,19 +46,19 @@ public class LoggingNHttpClientConnection extends DefaultNHttpClientConnection {
private final Log log;
private final Log iolog;
- private final Log headerlog;
- private final Log wirelog;
+ private final Log headerLog;
+ private final Log wireLog;
private final String id;
public LoggingNHttpClientConnection(final IOSession session) {
super(session, 8 * 1024);
this.log = LogFactory.getLog(getClass());
this.iolog = LogFactory.getLog(session.getClass());
- this.headerlog = LogFactory.getLog("org.apache.http.headers");
- this.wirelog = LogFactory.getLog("org.apache.http.wire");
+ this.headerLog = LogFactory.getLog("org.apache.http.headers");
+ this.wireLog = LogFactory.getLog("org.apache.http.wire");
this.id = "http-outgoing-" + COUNT.incrementAndGet();
- if (this.iolog.isDebugEnabled() || this.wirelog.isDebugEnabled()) {
- this.session = new LoggingIOSession(session, this.id, this.iolog, this.wirelog);
+ if (this.iolog.isDebugEnabled() || this.wireLog.isDebugEnabled()) {
+ this.session = new LoggingIOSession(session, this.id, this.iolog, this.wireLog);
}
}
@@ -104,22 +104,22 @@ public class LoggingNHttpClientConnection extends DefaultNHttpClientConnection {
@Override
protected void onResponseReceived(final HttpResponse response) {
- if (response != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(this.id + " << " + response.getStatusLine().toString());
+ if (response != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(this.id + " << " + response.getStatusLine().toString());
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 HttpRequest request) {
- if (request != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(id + " >> " + request.getRequestLine().toString());
+ if (request != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(id + " >> " + request.getRequestLine().toString());
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/07a4acf7/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpServerConnection.java b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpServerConnection.java
index 6004ef1..218dec8 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpServerConnection.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpServerConnection.java
@@ -46,19 +46,19 @@ public class LoggingNHttpServerConnection extends DefaultNHttpServerConnection {
private final Log log;
private final Log iolog;
- private final Log headerlog;
- private final Log wirelog;
+ private final Log headerLog;
+ private final Log wireLog;
private final String id;
public LoggingNHttpServerConnection(final IOSession session) {
super(session, 8 * 1024);
this.log = LogFactory.getLog(getClass());
this.iolog = LogFactory.getLog(session.getClass());
- this.headerlog = LogFactory.getLog("org.apache.http.headers");
- this.wirelog = LogFactory.getLog("org.apache.http.wire");
+ this.headerLog = LogFactory.getLog("org.apache.http.headers");
+ this.wireLog = LogFactory.getLog("org.apache.http.wire");
this.id = "http-incoming-" + COUNT.incrementAndGet();
- if (this.iolog.isDebugEnabled() || this.wirelog.isDebugEnabled()) {
- this.session = new LoggingIOSession(session, this.id, this.iolog, this.wirelog);
+ if (this.iolog.isDebugEnabled() || this.wireLog.isDebugEnabled()) {
+ this.session = new LoggingIOSession(session, this.id, this.iolog, this.wireLog);
}
}
@@ -104,22 +104,22 @@ public class LoggingNHttpServerConnection extends DefaultNHttpServerConnection {
@Override
protected void onRequestReceived(final HttpRequest request) {
- if (request != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(this.id + " >> " + request.getRequestLine().toString());
+ if (request != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(this.id + " >> " + request.getRequestLine().toString());
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 HttpResponse response) {
- if (response != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(this.id + " << " + response.getStatusLine().toString());
+ if (response != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(this.id + " << " + response.getStatusLine().toString());
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/07a4acf7/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ServerConnectionFactory.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ServerConnectionFactory.java b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ServerConnectionFactory.java
index 4c0b174..151212f 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ServerConnectionFactory.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ServerConnectionFactory.java
@@ -56,14 +56,14 @@ public class ServerConnectionFactory implements NHttpConnectionFactory<DefaultNH
}
@Override
- public DefaultNHttpServerConnection createConnection(final IOSession iosession) {
+ public DefaultNHttpServerConnection createConnection(final IOSession ioSession) {
if (this.sslContext != null) {
- final SSLIOSession ssliosession = new SSLIOSession(
- iosession, SSLMode.SERVER, this.sslContext, this.setupHandler);
- iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession);
- return new LoggingNHttpServerConnection(ssliosession);
+ final SSLIOSession sslioSession = new SSLIOSession(
+ ioSession, SSLMode.SERVER, this.sslContext, this.setupHandler);
+ ioSession.setAttribute(SSLIOSession.SESSION_KEY, sslioSession);
+ return new LoggingNHttpServerConnection(sslioSession);
} else {
- return new LoggingNHttpServerConnection(iosession);
+ return new LoggingNHttpServerConnection(ioSession);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpServerConnection.java b/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpServerConnection.java
index dcf190c..fce3f53 100644
--- a/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpServerConnection.java
+++ b/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpServerConnection.java
@@ -207,9 +207,8 @@ public class SocketHttpServerConnection extends
} catch (final SocketException ignore) {
return -1;
}
- } else {
- return -1;
}
+ return -1;
}
@Override
@@ -272,9 +271,8 @@ public class SocketHttpServerConnection extends
formatAddress(buffer, remoteAddress);
}
return buffer.toString();
- } else {
- return super.toString();
}
+ return super.toString();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java/org/apache/http/HttpHost.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/HttpHost.java b/httpcore/src/main/java/org/apache/http/HttpHost.java
index cbd5ac0..50bad3c 100644
--- a/httpcore/src/main/java/org/apache/http/HttpHost.java
+++ b/httpcore/src/main/java/org/apache/http/HttpHost.java
@@ -287,9 +287,8 @@ public final class HttpHost implements Cloneable, Serializable {
buffer.append(":");
buffer.append(Integer.toString(this.port));
return buffer.toString();
- } else {
- return this.hostname;
}
+ return this.hostname;
}
@@ -310,9 +309,8 @@ public final class HttpHost implements Cloneable, Serializable {
&& this.port == that.port
&& this.schemeName.equals(that.schemeName)
&& (this.address==null ? that.address== null : this.address.equals(that.address));
- } else {
- return false;
}
+ return false;
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java b/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java
index b8b2ca1..5402d4c 100644
--- a/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java
+++ b/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java
@@ -100,11 +100,10 @@ public class BasicFuture<T> implements Future<T>, Cancellable {
wait(waitTime);
if (this.completed) {
return getResult();
- } else {
- waitTime = msecs - (System.currentTimeMillis() - startTime);
- if (waitTime <= 0) {
- throw new TimeoutException();
- }
+ }
+ waitTime = msecs - (System.currentTimeMillis() - startTime);
+ if (waitTime <= 0) {
+ throw new TimeoutException();
}
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java b/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java
index 4466aec..7b2330f 100644
--- a/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java
+++ b/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java
@@ -69,20 +69,12 @@ public class BufferedHttpEntity extends HttpEntityWrapper {
@Override
public long getContentLength() {
- if (this.buffer != null) {
- return this.buffer.length;
- } else {
- return super.getContentLength();
- }
+ return this.buffer != null ? this.buffer.length : super.getContentLength();
}
@Override
public InputStream getContent() throws IOException {
- if (this.buffer != null) {
- return new ByteArrayInputStream(this.buffer);
- } else {
- return super.getContent();
- }
+ return this.buffer != null ? new ByteArrayInputStream(this.buffer) : super.getContent();
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java/org/apache/http/entity/ContentType.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/ContentType.java b/httpcore/src/main/java/org/apache/http/entity/ContentType.java
index 8398ddb..be2b43c 100644
--- a/httpcore/src/main/java/org/apache/http/entity/ContentType.java
+++ b/httpcore/src/main/java/org/apache/http/entity/ContentType.java
@@ -315,9 +315,8 @@ public final class ContentType implements Serializable {
final HeaderElement[] elements = BasicHeaderValueParser.INSTANCE.parseElements(buf, cursor);
if (elements.length > 0) {
return create(elements[0], true);
- } else {
- throw new ParseException("Invalid content type: " + s);
}
+ throw new ParseException("Invalid content type: " + s);
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java b/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
index 165f9a9..cedd6a0 100644
--- a/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
+++ b/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
@@ -88,9 +88,9 @@ public class BHttpConnectionBase implements HttpInetConnection {
*
* @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @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 messageConstraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
@@ -102,8 +102,8 @@ public class BHttpConnectionBase implements HttpInetConnection {
protected BHttpConnectionBase(
final int bufferSize,
final int fragmentSizeHint,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints messageConstraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy) {
@@ -112,9 +112,9 @@ public class BHttpConnectionBase implements HttpInetConnection {
final HttpTransportMetricsImpl inTransportMetrics = new HttpTransportMetricsImpl();
final HttpTransportMetricsImpl outTransportMetrics = new HttpTransportMetricsImpl();
this.inBuffer = new SessionInputBufferImpl(inTransportMetrics, bufferSize, -1,
- messageConstraints != null ? messageConstraints : MessageConstraints.DEFAULT, chardecoder);
+ messageConstraints != null ? messageConstraints : MessageConstraints.DEFAULT, charDecoder);
this.outbuffer = new SessionOutputBufferImpl(outTransportMetrics, bufferSize, fragmentSizeHint,
- charencoder);
+ charEncoder);
this.messageConstraints = messageConstraints;
this.connMetrics = new HttpConnectionMetricsImpl(inTransportMetrics, outTransportMetrics);
this.incomingContentStrategy = incomingContentStrategy != null ? incomingContentStrategy :
@@ -291,9 +291,8 @@ public class BHttpConnectionBase implements HttpInetConnection {
} catch (final SocketException ignore) {
return -1;
}
- } else {
- return -1;
}
+ return -1;
}
@Override
@@ -395,9 +394,8 @@ public class BHttpConnectionBase implements HttpInetConnection {
NetUtils.formatAddress(buffer, remoteAddress);
}
return buffer.toString();
- } else {
- return "[Not bound]";
}
+ return "[Not bound]";
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java/org/apache/http/impl/ConnSupport.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/ConnSupport.java b/httpcore/src/main/java/org/apache/http/impl/ConnSupport.java
index a957629..d4320c3 100644
--- a/httpcore/src/main/java/org/apache/http/impl/ConnSupport.java
+++ b/httpcore/src/main/java/org/apache/http/impl/ConnSupport.java
@@ -51,9 +51,8 @@ public final class ConnSupport {
return charset.newDecoder()
.onMalformedInput(malformed != null ? malformed : CodingErrorAction.REPORT)
.onUnmappableCharacter(unmappable != null ? unmappable: CodingErrorAction.REPORT);
- } else {
- return null;
}
+ return null;
}
public static CharsetEncoder createEncoder(final ConnectionConfig cconfig) {
@@ -67,9 +66,8 @@ public final class ConnSupport {
return charset.newEncoder()
.onMalformedInput(malformed != null ? malformed : CodingErrorAction.REPORT)
.onUnmappableCharacter(unmappable != null ? unmappable: CodingErrorAction.REPORT);
- } else {
- return null;
}
+ return null;
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java b/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
index 44c614a..5ace305 100644
--- a/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
+++ b/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
@@ -67,9 +67,9 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
*
* @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @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 constraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
@@ -85,14 +85,14 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
public DefaultBHttpClientConnection(
final int bufferSize,
final int fragmentSizeHint,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
- super(bufferSize, fragmentSizeHint, chardecoder, charencoder,
+ super(bufferSize, fragmentSizeHint, charDecoder, charEncoder,
constraints, incomingContentStrategy, outgoingContentStrategy);
this.requestWriter = (requestWriterFactory != null ? requestWriterFactory :
DefaultHttpRequestWriterFactory.INSTANCE).create(getSessionOutputBuffer());
@@ -102,10 +102,10 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
public DefaultBHttpClientConnection(
final int bufferSize,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints) {
- this(bufferSize, bufferSize, chardecoder, charencoder, constraints, null, null, null, null);
+ this(bufferSize, bufferSize, charDecoder, charEncoder, constraints, null, null, null, null);
}
public DefaultBHttpClientConnection(final int bufferSize) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java b/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
index 5e9f65d..26a8a58 100644
--- a/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
+++ b/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
@@ -65,9 +65,9 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
*
* @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @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 constraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
@@ -83,14 +83,14 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
public DefaultBHttpServerConnection(
final int bufferSize,
final int fragmentSizeHint,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageParserFactory<HttpRequest> requestParserFactory,
final HttpMessageWriterFactory<HttpResponse> responseWriterFactory) {
- super(bufferSize, fragmentSizeHint, chardecoder, charencoder, constraints,
+ super(bufferSize, fragmentSizeHint, charDecoder, charEncoder, constraints,
incomingContentStrategy != null ? incomingContentStrategy :
DisallowIdentityContentLengthStrategy.INSTANCE, outgoingContentStrategy);
this.requestParser = (requestParserFactory != null ? requestParserFactory :
@@ -101,10 +101,10 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
public DefaultBHttpServerConnection(
final int bufferSize,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints) {
- this(bufferSize, bufferSize, chardecoder, charencoder, constraints, null, null, null, null);
+ this(bufferSize, bufferSize, charDecoder, charEncoder, constraints, null, null, null, null);
}
public DefaultBHttpServerConnection(final int bufferSize) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java/org/apache/http/impl/HttpConnectionMetricsImpl.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/HttpConnectionMetricsImpl.java b/httpcore/src/main/java/org/apache/http/impl/HttpConnectionMetricsImpl.java
index c3106c5..b9f786c 100644
--- a/httpcore/src/main/java/org/apache/http/impl/HttpConnectionMetricsImpl.java
+++ b/httpcore/src/main/java/org/apache/http/impl/HttpConnectionMetricsImpl.java
@@ -67,20 +67,12 @@ public class HttpConnectionMetricsImpl implements HttpConnectionMetrics {
@Override
public long getReceivedBytesCount() {
- if (this.inTransportMetric != null) {
- return this.inTransportMetric.getBytesTransferred();
- } else {
- return -1;
- }
+ return this.inTransportMetric != null ? this.inTransportMetric.getBytesTransferred() : -1;
}
@Override
public long getSentBytesCount() {
- if (this.outTransportMetric != null) {
- return this.outTransportMetric.getBytesTransferred();
- } else {
- return -1;
- }
+ return this.outTransportMetric != null ? this.outTransportMetric.getBytesTransferred() : -1;
}
@Override
@@ -113,17 +105,13 @@ public class HttpConnectionMetricsImpl implements HttpConnectionMetrics {
} else if (RESPONSE_COUNT.equals(metricName)) {
value = Long.valueOf(responseCount);
} else if (RECEIVED_BYTES_COUNT.equals(metricName)) {
- if (this.inTransportMetric != null) {
- return Long.valueOf(this.inTransportMetric.getBytesTransferred());
- } else {
- return null;
- }
+ return this.inTransportMetric != null
+ ? Long.valueOf(this.inTransportMetric.getBytesTransferred())
+ : null;
} else if (SENT_BYTES_COUNT.equals(metricName)) {
- if (this.outTransportMetric != null) {
- return Long.valueOf(this.outTransportMetric.getBytesTransferred());
- } else {
- return null;
- }
+ return this.outTransportMetric != null
+ ? Long.valueOf(this.outTransportMetric.getBytesTransferred())
+ : null;
}
}
return value;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java/org/apache/http/impl/bootstrap/HttpServer.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/bootstrap/HttpServer.java b/httpcore/src/main/java/org/apache/http/impl/bootstrap/HttpServer.java
index 696aae5..c2eef30 100644
--- a/httpcore/src/main/java/org/apache/http/impl/bootstrap/HttpServer.java
+++ b/httpcore/src/main/java/org/apache/http/impl/bootstrap/HttpServer.java
@@ -99,20 +99,12 @@ public class HttpServer {
public InetAddress getInetAddress() {
final ServerSocket localSocket = this.serverSocket;
- if (localSocket != null) {
- return localSocket.getInetAddress();
- } else {
- return null;
- }
+ return localSocket != null ? localSocket.getInetAddress() : null;
}
public int getLocalPort() {
final ServerSocket localSocket = this.serverSocket;
- if (localSocket != null) {
- return localSocket.getLocalPort();
- } else {
- return -1;
- }
+ return localSocket != null ? localSocket.getLocalPort() : -1;
}
public void start() throws IOException {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java b/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
index d5dd611..aa18110 100644
--- a/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
+++ b/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
@@ -105,22 +105,18 @@ public class LaxContentLengthStrategy implements ContentLengthStrategy {
}
final Header contentLengthHeader = message.getFirstHeader(HTTP.CONTENT_LEN);
if (contentLengthHeader != null) {
- long contentlen = -1;
+ long contentLen = -1;
final Header[] headers = message.getHeaders(HTTP.CONTENT_LEN);
for (int i = headers.length - 1; i >= 0; i--) {
final Header header = headers[i];
try {
- contentlen = Long.parseLong(header.getValue());
+ contentLen = Long.parseLong(header.getValue());
break;
} catch (final NumberFormatException ignore) {
}
// See if we can have better luck with another header, if present
}
- if (contentlen >= 0) {
- return contentlen;
- } else {
- return IDENTITY;
- }
+ return contentLen >= 0 ? contentLen : IDENTITY;
}
return this.implicitLen;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java b/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
index 68fe740..7456c15 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
@@ -119,9 +119,8 @@ public class ChunkedInputStream extends InputStream {
if (this.in instanceof BufferInfo) {
final int len = ((BufferInfo) this.in).length();
return (int) Math.min(len, this.chunkSize - this.pos);
- } else {
- return 0;
}
+ return 0;
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java b/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
index c4d8848..f2617d1 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
@@ -114,9 +114,8 @@ public class ContentLengthInputStream extends InputStream {
if (this.in instanceof BufferInfo) {
final int len = ((BufferInfo) this.in).length();
return Math.min(len, (int) (this.contentLength - this.pos));
- } else {
- return 0;
}
+ return 0;
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java b/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java
index 19175bc..c5883c1 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java
@@ -73,21 +73,21 @@ public class SessionOutputBufferImpl implements SessionOutputBuffer, BufferInfo
* @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 HttpTransportMetricsImpl 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 : 0;
- this.encoder = charencoder;
+ this.encoder = charEncoder;
}
public SessionOutputBufferImpl(
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java b/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java
index 1182d10..71ac53e 100644
--- a/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java
+++ b/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java
@@ -124,9 +124,8 @@ public class BasicHeaderElement implements HeaderElement, Cloneable {
return this.name.equals(that.name)
&& LangUtils.equals(this.value, that.value)
&& LangUtils.equals(this.parameters, that.parameters);
- } else {
- return false;
}
+ return false;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/07a4acf7/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java b/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java
index 4bd16e8..2d9320d 100644
--- a/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java
+++ b/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java
@@ -77,14 +77,13 @@ public class BasicHeaderElementIterator implements HeaderElementIterator {
this.cursor = new ParserCursor(0, this.buffer.length());
this.cursor.updatePos(((FormattedHeader) h).getValuePos());
break;
- } else {
- final String value = h.getValue();
- if (value != null) {
- this.buffer = new CharArrayBuffer(value.length());
- this.buffer.append(value);
- this.cursor = new ParserCursor(0, this.buffer.length());
- break;
- }
+ }
+ final String value = h.getValue();
+ if (value != null) {
+ this.buffer = new CharArrayBuffer(value.length());
+ this.buffer.append(value);
+ this.cursor = new ParserCursor(0, this.buffer.length());
+ break;
}
}
}