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 19:01:25 UTC
[1/3] httpcomponents-client 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.) - Remove redund [Forced Update!]
Repository: httpcomponents-client
Updated Branches:
refs/heads/4.5.x 2e06a435d -> e6c226d5f (forced update)
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/client/TestAbstractResponseHandler.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestAbstractResponseHandler.java b/httpclient/src/test/java/org/apache/http/impl/client/TestAbstractResponseHandler.java
index 6a2930c..cfc2bd6 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestAbstractResponseHandler.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestAbstractResponseHandler.java
@@ -69,10 +69,10 @@ public class TestAbstractResponseHandler {
@SuppressWarnings("boxing")
@Test
public void testUnsuccessfulResponse() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
+ final InputStream inStream = Mockito.mock(InputStream.class);
final HttpEntity entity = Mockito.mock(HttpEntity.class);
Mockito.when(entity.isStreaming()).thenReturn(true);
- Mockito.when(entity.getContent()).thenReturn(instream);
+ Mockito.when(entity.getContent()).thenReturn(inStream);
final StatusLine sl = new BasicStatusLine(HttpVersion.HTTP_1_1, 404, "Not Found");
final HttpResponse response = Mockito.mock(HttpResponse.class);
Mockito.when(response.getStatusLine()).thenReturn(sl);
@@ -87,7 +87,7 @@ public class TestAbstractResponseHandler {
Assert.assertEquals("Not Found", ex.getMessage());
}
Mockito.verify(entity).getContent();
- Mockito.verify(instream).close();
+ Mockito.verify(inStream).close();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCookieStore.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCookieStore.java b/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCookieStore.java
index a329758..6760345 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCookieStore.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCookieStore.java
@@ -49,15 +49,15 @@ public class TestBasicCookieStore {
final BasicCookieStore store = new BasicCookieStore();
store.addCookie(new BasicClientCookie("name1", "value1"));
store.addCookies(new BasicClientCookie[] {new BasicClientCookie("name2", "value2")});
- List<Cookie> l = store.getCookies();
- Assert.assertNotNull(l);
- Assert.assertEquals(2, l.size());
- Assert.assertEquals("name1", l.get(0).getName());
- Assert.assertEquals("name2", l.get(1).getName());
+ List<Cookie> list = store.getCookies();
+ Assert.assertNotNull(list);
+ Assert.assertEquals(2, list.size());
+ Assert.assertEquals("name1", list.get(0).getName());
+ Assert.assertEquals("name2", list.get(1).getName());
store.clear();
- l = store.getCookies();
- Assert.assertNotNull(l);
- Assert.assertEquals(0, l.size());
+ list = store.getCookies();
+ Assert.assertNotNull(list);
+ Assert.assertEquals(0, list.size());
}
@Test
@@ -80,13 +80,13 @@ public class TestBasicCookieStore {
orig.addCookie(new BasicClientCookie("name1", "value1"));
orig.addCookie(new BasicClientCookie("name2", "value2"));
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final BasicCookieStore clone = (BasicCookieStore) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final BasicCookieStore clone = (BasicCookieStore) inStream.readObject();
final List<Cookie> expected = orig.getCookies();
final List<Cookie> clones = clone.getCookies();
Assert.assertNotNull(expected);
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/client/TestBasicResponseHandler.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestBasicResponseHandler.java b/httpclient/src/test/java/org/apache/http/impl/client/TestBasicResponseHandler.java
index 8a4f0ed..8bb0a43 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestBasicResponseHandler.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestBasicResponseHandler.java
@@ -61,10 +61,10 @@ public class TestBasicResponseHandler {
@Test
public void testUnsuccessfulResponse() throws Exception {
- final InputStream instream = Mockito.mock(InputStream.class);
+ final InputStream inStream = Mockito.mock(InputStream.class);
final HttpEntity entity = Mockito.mock(HttpEntity.class);
Mockito.when(entity.isStreaming()).thenReturn(true);
- Mockito.when(entity.getContent()).thenReturn(instream);
+ Mockito.when(entity.getContent()).thenReturn(inStream);
final StatusLine sl = new BasicStatusLine(HttpVersion.HTTP_1_1, 404, "Not Found");
final HttpResponse response = Mockito.mock(HttpResponse.class);
Mockito.when(response.getStatusLine()).thenReturn(sl);
@@ -79,7 +79,7 @@ public class TestBasicResponseHandler {
Assert.assertEquals("Not Found", ex.getMessage());
}
Mockito.verify(entity).getContent();
- Mockito.verify(instream).close();
+ Mockito.verify(inStream).close();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/client/TestIdleConnectionEvictor.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestIdleConnectionEvictor.java b/httpclient/src/test/java/org/apache/http/impl/client/TestIdleConnectionEvictor.java
index 135f634..da0d9bd 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestIdleConnectionEvictor.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestIdleConnectionEvictor.java
@@ -32,6 +32,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.http.conn.HttpClientConnectionManager;
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.Matchers;
import org.mockito.Mockito;
/**
@@ -68,7 +69,7 @@ public class TestIdleConnectionEvictor {
Thread.sleep(1000);
Mockito.verify(cm, Mockito.atLeast(1)).closeExpiredConnections();
- Mockito.verify(cm, Mockito.never()).closeIdleConnections(Mockito.anyLong(), Mockito.<TimeUnit>any());
+ Mockito.verify(cm, Mockito.never()).closeIdleConnections(Matchers.anyLong(), Matchers.<TimeUnit>any());
Assert.assertTrue(connectionEvictor.isRunning());
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
index 282e11b..67f058d 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
@@ -373,20 +373,19 @@ public class TestAbortHandling extends LocalServerTestBase {
@Override
public HttpClientConnection get(
final long timeout,
- final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
+ final TimeUnit timeUnit) throws InterruptedException, ConnectionPoolTimeoutException {
connLatch.countDown(); // notify waiter that we're getting a connection
// zero usually means sleep forever, but CountDownLatch doesn't interpret it that way.
- if(!awaitLatch.await(timeout > 0 ? timeout : Integer.MAX_VALUE, tunit)) {
+ if(!awaitLatch.await(timeout > 0 ? timeout : Integer.MAX_VALUE, timeUnit)) {
throw new ConnectionPoolTimeoutException();
}
return Mockito.mock(HttpClientConnection.class);
}
};
- } else {
- return super.requestConnection(route, state);
}
+ return super.requestConnection(route, state);
}
}
@@ -401,7 +400,7 @@ public class TestAbortHandling extends LocalServerTestBase {
}
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
throw new UnsupportedOperationException("just a mockup");
}
@@ -411,7 +410,7 @@ public class TestAbortHandling extends LocalServerTestBase {
}
public HttpClientConnection getConnection(final HttpRoute route,
- final long timeout, final TimeUnit tunit) {
+ final long timeout, final TimeUnit timeUnit) {
throw new UnsupportedOperationException("just a mockup");
}
@@ -433,11 +432,11 @@ public class TestAbortHandling extends LocalServerTestBase {
@Override
public HttpClientConnection get(
final long timeout,
- final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
+ final TimeUnit timeUnit) throws InterruptedException, ConnectionPoolTimeoutException {
connLatch.countDown(); // notify waiter that we're getting a connection
// zero usually means sleep forever, but CountDownLatch doesn't interpret it that way.
- if(!awaitLatch.await(timeout > 0 ? timeout : Integer.MAX_VALUE, tunit)) {
+ if(!awaitLatch.await(timeout > 0 ? timeout : Integer.MAX_VALUE, timeUnit)) {
throw new ConnectionPoolTimeoutException();
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java
index a4de80d..63451d4 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java
@@ -178,10 +178,10 @@ public class TestConnectionAutoRelease extends LocalServerTestBase {
@Override
public void writeTo(
- final OutputStream outstream) throws IOException {
+ final OutputStream outStream) throws IOException {
final byte[] tmp = new byte[5];
- outstream.write(tmp);
- outstream.flush();
+ outStream.write(tmp);
+ outStream.flush();
// do something comletely ugly in order to trigger
// MalformedChunkCodingException
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMalformedServerResponse.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMalformedServerResponse.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMalformedServerResponse.java
index b18f8fc..9dc8f6d 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMalformedServerResponse.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMalformedServerResponse.java
@@ -50,8 +50,8 @@ public class TestMalformedServerResponse extends LocalServerTestBase {
static class BrokenServerConnection extends DefaultBHttpServerConnection {
- public BrokenServerConnection(final int buffersize) {
- super(buffersize);
+ public BrokenServerConnection(final int bufferSize) {
+ super(bufferSize);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/conn/SessionInputBufferMock.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/conn/SessionInputBufferMock.java b/httpclient/src/test/java/org/apache/http/impl/conn/SessionInputBufferMock.java
index 15c9f20..f1ca207 100644
--- a/httpclient/src/test/java/org/apache/http/impl/conn/SessionInputBufferMock.java
+++ b/httpclient/src/test/java/org/apache/http/impl/conn/SessionInputBufferMock.java
@@ -45,39 +45,39 @@ public class SessionInputBufferMock extends SessionInputBufferImpl {
public static final int BUFFER_SIZE = 16;
public SessionInputBufferMock(
- final InputStream instream,
- final int buffersize,
+ final InputStream inStream,
+ final int bufferSize,
final MessageConstraints constrains,
final CharsetDecoder decoder) {
- super(new HttpTransportMetricsImpl(), buffersize, -1, constrains, decoder);
- bind(instream);
+ super(new HttpTransportMetricsImpl(), bufferSize, -1, constrains, decoder);
+ bind(inStream);
}
public SessionInputBufferMock(
- final InputStream instream,
- final int buffersize) {
- this(instream, buffersize, null, null);
+ final InputStream inStream,
+ final int bufferSize) {
+ this(inStream, bufferSize, null, null);
}
public SessionInputBufferMock(
final byte[] bytes,
- final int buffersize,
+ final int bufferSize,
final MessageConstraints constrains,
final CharsetDecoder decoder) {
- this(new ByteArrayInputStream(bytes), buffersize, constrains, decoder);
+ this(new ByteArrayInputStream(bytes), bufferSize, constrains, decoder);
}
public SessionInputBufferMock(
final byte[] bytes,
- final int buffersize,
+ final int bufferSize,
final MessageConstraints constrains) {
- this(new ByteArrayInputStream(bytes), buffersize, constrains, null);
+ this(new ByteArrayInputStream(bytes), bufferSize, constrains, null);
}
public SessionInputBufferMock(
final byte[] bytes,
- final int buffersize) {
- this(new ByteArrayInputStream(bytes), buffersize);
+ final int bufferSize) {
+ this(new ByteArrayInputStream(bytes), bufferSize);
}
public SessionInputBufferMock(
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java b/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java
index 207cddc..da26ebd 100644
--- a/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java
+++ b/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java
@@ -55,8 +55,8 @@ public class TestDefaultHttpResponseParser {
"header2: value2\r\n" +
"\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts.ASCII);
- final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(inbuffer);
+ final SessionInputBuffer inBuffer = new SessionInputBufferMock(s, Consts.ASCII);
+ final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(inBuffer);
final HttpResponse response = parser.parse();
Assert.assertNotNull(response);
@@ -81,8 +81,8 @@ public class TestDefaultHttpResponseParser {
"header2: value2\r\n" +
"\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts.ASCII);
- final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(inbuffer) {
+ final SessionInputBuffer inBuffer = new SessionInputBufferMock(s, Consts.ASCII);
+ final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(inBuffer) {
@Override
protected boolean reject(final CharArrayBuffer line, final int count) {
@@ -95,8 +95,8 @@ public class TestDefaultHttpResponseParser {
@Test(expected=NoHttpResponseException.class)
public void testResponseParsingNoResponse() throws Exception {
- final SessionInputBuffer inbuffer = new SessionInputBufferMock("", Consts.ASCII);
- final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(inbuffer);
+ final SessionInputBuffer inBuffer = new SessionInputBufferMock("", Consts.ASCII);
+ final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(inBuffer);
parser.parse();
}
@@ -107,8 +107,8 @@ public class TestDefaultHttpResponseParser {
"garbage\r\n" +
"more garbage\r\n" +
"a lot more garbage\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts.ASCII);
- final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(inbuffer);
+ final SessionInputBuffer inBuffer = new SessionInputBufferMock(s, Consts.ASCII);
+ final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(inBuffer);
parser.parse();
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie.java b/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie.java
index c807a2f..d1378b0 100644
--- a/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie.java
+++ b/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie.java
@@ -75,13 +75,13 @@ public class TestBasicClientCookie {
orig.setPath("/");
orig.setAttribute("attrib", "stuff");
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final BasicClientCookie clone = (BasicClientCookie) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final BasicClientCookie clone = (BasicClientCookie) inStream.readObject();
Assert.assertEquals(orig.getName(), clone.getName());
Assert.assertEquals(orig.getValue(), clone.getValue());
Assert.assertEquals(orig.getDomain(), clone.getDomain());
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie2.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie2.java b/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie2.java
index 9af1608..31fad7d 100644
--- a/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie2.java
+++ b/httpclient/src/test/java/org/apache/http/impl/cookie/TestBasicClientCookie2.java
@@ -95,13 +95,13 @@ public class TestBasicClientCookie2 {
orig.setAttribute("attrib", "stuff");
orig.setPorts(new int[] {80, 8080});
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final BasicClientCookie2 clone = (BasicClientCookie2) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final BasicClientCookie2 clone = (BasicClientCookie2) inStream.readObject();
Assert.assertEquals(orig.getName(), clone.getName());
Assert.assertEquals(orig.getValue(), clone.getValue());
Assert.assertEquals(orig.getDomain(), clone.getDomain());
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/cookie/TestRFC6265CookieSpec.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/cookie/TestRFC6265CookieSpec.java b/httpclient/src/test/java/org/apache/http/impl/cookie/TestRFC6265CookieSpec.java
index fc6adf1..35753fd 100644
--- a/httpclient/src/test/java/org/apache/http/impl/cookie/TestRFC6265CookieSpec.java
+++ b/httpclient/src/test/java/org/apache/http/impl/cookie/TestRFC6265CookieSpec.java
@@ -40,6 +40,7 @@ import org.apache.http.cookie.SetCookie;
import org.apache.http.message.BasicHeader;
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.Matchers;
import org.mockito.Mockito;
public class TestRFC6265CookieSpec {
@@ -68,8 +69,8 @@ public class TestRFC6265CookieSpec {
Assert.assertEquals("stuff", clientCookie.getAttribute("this"));
Assert.assertEquals(null, clientCookie.getAttribute("that"));
- Mockito.verify(h1).parse(Mockito.<SetCookie>any(), Mockito.eq("stuff"));
- Mockito.verify(h2, Mockito.never()).parse(Mockito.<SetCookie>any(), Mockito.anyString());
+ Mockito.verify(h1).parse(Matchers.<SetCookie>any(), Matchers.eq("stuff"));
+ Mockito.verify(h2, Mockito.never()).parse(Matchers.<SetCookie>any(), Matchers.anyString());
}
@Test
@@ -315,8 +316,8 @@ public class TestRFC6265CookieSpec {
final CookieOrigin origin = new CookieOrigin("host", 80, "/path/", true);
cookiespec.parse(header, origin);
- Mockito.verify(h1).parse(Mockito.<SetCookie>any(), Mockito.eq("morestuff"));
- Mockito.verify(h1, Mockito.times(1)).parse(Mockito.<SetCookie>any(), Mockito.anyString());
+ Mockito.verify(h1).parse(Matchers.<SetCookie>any(), Matchers.eq("morestuff"));
+ Mockito.verify(h1, Mockito.times(1)).parse(Matchers.<SetCookie>any(), Matchers.anyString());
}
@Test
@@ -332,8 +333,8 @@ public class TestRFC6265CookieSpec {
final CookieOrigin origin = new CookieOrigin("host", 80, "/path/", true);
cookiespec.parse(header, origin);
- Mockito.verify(h1, Mockito.never()).parse(Mockito.<SetCookie>any(), Mockito.anyString());
- Mockito.verify(h2).parse(Mockito.<SetCookie>any(), Mockito.eq("otherstuff"));
+ Mockito.verify(h1, Mockito.never()).parse(Matchers.<SetCookie>any(), Matchers.anyString());
+ Mockito.verify(h2).parse(Matchers.<SetCookie>any(), Matchers.eq("otherstuff"));
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java
index 2261da8..7de9921 100644
--- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java
+++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java
@@ -418,14 +418,14 @@ public class TestMainClientExec {
final HttpClientContext context = new HttpClientContext();
final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
final HttpResponse response1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 401, "Huh?");
- final InputStream instream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
+ final InputStream inStream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
response1.setEntity(EntityBuilder.create()
- .setStream(instream1)
+ .setStream(inStream1)
.build());
final HttpResponse response2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
- final InputStream instream2 = Mockito.spy(new ByteArrayInputStream(new byte[] {2, 3, 4}));
+ final InputStream inStream2 = Mockito.spy(new ByteArrayInputStream(new byte[] {2, 3, 4}));
response2.setEntity(EntityBuilder.create()
- .setStream(instream2)
+ .setStream(inStream2)
.build());
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.TRUE);
@@ -445,8 +445,8 @@ public class TestMainClientExec {
final CloseableHttpResponse finalResponse = mainClientExec.execute(
route, request, context, execAware);
Mockito.verify(requestExecutor, Mockito.times(2)).execute(request, managedConn, context);
- Mockito.verify(instream1).close();
- Mockito.verify(instream2, Mockito.never()).close();
+ Mockito.verify(inStream1).close();
+ Mockito.verify(inStream2, Mockito.never()).close();
Assert.assertNotNull(finalResponse);
Assert.assertEquals(200, finalResponse.getStatusLine().getStatusCode());
@@ -457,14 +457,14 @@ public class TestMainClientExec {
final HttpRoute route = new HttpRoute(target);
final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
final HttpResponse response1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 401, "Huh?");
- final InputStream instream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
+ final InputStream inStream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
response1.setEntity(EntityBuilder.create()
- .setStream(instream1)
+ .setStream(inStream1)
.build());
final HttpResponse response2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
- final InputStream instream2 = Mockito.spy(new ByteArrayInputStream(new byte[] {2, 3, 4}));
+ final InputStream inStream2 = Mockito.spy(new ByteArrayInputStream(new byte[] {2, 3, 4}));
response2.setEntity(EntityBuilder.create()
- .setStream(instream2)
+ .setStream(inStream2)
.build());
final AuthState proxyAuthState = new AuthState();
@@ -492,7 +492,7 @@ public class TestMainClientExec {
route, request, context, execAware);
Mockito.verify(requestExecutor, Mockito.times(2)).execute(request, managedConn, context);
Mockito.verify(managedConn).close();
- Mockito.verify(instream2, Mockito.never()).close();
+ Mockito.verify(inStream2, Mockito.never()).close();
Assert.assertNotNull(finalResponse);
Assert.assertEquals(200, finalResponse.getStatusLine().getStatusCode());
@@ -505,16 +505,16 @@ public class TestMainClientExec {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
final HttpPost post = new HttpPost("http://bar/test");
- final InputStream instream0 = new ByteArrayInputStream(new byte[] {1, 2, 3});
+ final InputStream inStream0 = new ByteArrayInputStream(new byte[] {1, 2, 3});
post.setEntity(EntityBuilder.create()
- .setStream(instream0)
+ .setStream(inStream0)
.build());
final HttpRequestWrapper request = HttpRequestWrapper.wrap(post);
final HttpResponse response1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 401, "Huh?");
- final InputStream instream1 = new ByteArrayInputStream(new byte[] {1, 2, 3});
+ final InputStream inStream1 = new ByteArrayInputStream(new byte[] {1, 2, 3});
response1.setEntity(EntityBuilder.create()
- .setStream(instream1)
+ .setStream(inStream1)
.build());
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.TRUE);
@@ -733,9 +733,9 @@ public class TestMainClientExec {
final HttpClientContext context = new HttpClientContext();
final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
final HttpResponse response1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 401, "Huh?");
- final InputStream instream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
+ final InputStream inStream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
response1.setEntity(EntityBuilder.create()
- .setStream(instream1)
+ .setStream(inStream1)
.build());
final HttpResponse response2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
@@ -756,7 +756,7 @@ public class TestMainClientExec {
Mockito.verify(connManager).connect(managedConn, route, 0, context);
Mockito.verify(connManager).routeComplete(managedConn, route, context);
- Mockito.verify(instream1).close();
+ Mockito.verify(inStream1).close();
}
@Test
@@ -766,9 +766,9 @@ public class TestMainClientExec {
final HttpClientContext context = new HttpClientContext();
final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
final HttpResponse response1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 401, "Huh?");
- final InputStream instream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
+ final InputStream inStream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
response1.setEntity(EntityBuilder.create()
- .setStream(instream1)
+ .setStream(inStream1)
.build());
final HttpResponse response2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
@@ -789,7 +789,7 @@ public class TestMainClientExec {
Mockito.verify(connManager).connect(managedConn, route, 0, context);
Mockito.verify(connManager).routeComplete(managedConn, route, context);
- Mockito.verify(instream1, Mockito.never()).close();
+ Mockito.verify(inStream1, Mockito.never()).close();
Mockito.verify(managedConn).close();
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java
index 5621a3f..a5d0591 100644
--- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java
+++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java
@@ -96,15 +96,15 @@ public class TestRedirectExec {
final HttpClientContext context = HttpClientContext.create();
final CloseableHttpResponse response1 = Mockito.mock(CloseableHttpResponse.class);
- final InputStream instream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
+ final InputStream inStream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
final HttpEntity entity1 = EntityBuilder.create()
- .setStream(instream1)
+ .setStream(inStream1)
.build();
Mockito.when(response1.getEntity()).thenReturn(entity1);
final CloseableHttpResponse response2 = Mockito.mock(CloseableHttpResponse.class);
- final InputStream instream2 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
+ final InputStream inStream2 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
final HttpEntity entity2 = EntityBuilder.create()
- .setStream(instream2)
+ .setStream(inStream2)
.build();
Mockito.when(response2.getEntity()).thenReturn(entity2);
final HttpGet redirect = new HttpGet("http://localhost:80/redirect");
@@ -154,9 +154,9 @@ public class TestRedirectExec {
Assert.assertEquals("that", headers[1].getValue());
Mockito.verify(response1, Mockito.times(1)).close();
- Mockito.verify(instream1, Mockito.times(1)).close();
+ Mockito.verify(inStream1, Mockito.times(1)).close();
Mockito.verify(response2, Mockito.never()).close();
- Mockito.verify(instream2, Mockito.never()).close();
+ Mockito.verify(inStream2, Mockito.never()).close();
}
@Test(expected = RedirectException.class)
@@ -321,9 +321,9 @@ public class TestRedirectExec {
final HttpClientContext context = HttpClientContext.create();
final CloseableHttpResponse response1 = Mockito.mock(CloseableHttpResponse.class);
- final InputStream instream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
+ final InputStream inStream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
final HttpEntity entity1 = EntityBuilder.create()
- .setStream(instream1)
+ .setStream(inStream1)
.build();
Mockito.when(response1.getEntity()).thenReturn(entity1);
Mockito.when(requestExecutor.execute(
@@ -343,7 +343,7 @@ public class TestRedirectExec {
try {
redirectExec.execute(route, request, context, execAware);
} catch (final Exception ex) {
- Mockito.verify(instream1).close();
+ Mockito.verify(inStream1).close();
Mockito.verify(response1).close();
throw ex;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/execchain/TestResponseEntityWrapper.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestResponseEntityWrapper.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestResponseEntityWrapper.java
index 803cb94..b4b2b77 100644
--- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestResponseEntityWrapper.java
+++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestResponseEntityWrapper.java
@@ -41,16 +41,16 @@ import org.mockito.Mockito;
@SuppressWarnings("boxing") // test code
public class TestResponseEntityWrapper {
- private InputStream instream;
+ private InputStream inStream;
private HttpEntity entity;
private ConnectionHolder connHolder;
private ResponseEntityProxy wrapper;
@Before
public void setup() throws Exception {
- instream = Mockito.mock(InputStream.class);
+ inStream = Mockito.mock(InputStream.class);
entity = Mockito.mock(HttpEntity.class);
- Mockito.when(entity.getContent()).thenReturn(instream);
+ Mockito.when(entity.getContent()).thenReturn(inStream);
connHolder = Mockito.mock(ConnectionHolder.class);
wrapper = new ResponseEntityProxy(entity, connHolder);
}
@@ -61,7 +61,7 @@ public class TestResponseEntityWrapper {
Mockito.when(connHolder.isReusable()).thenReturn(true);
EntityUtils.consume(wrapper);
- Mockito.verify(instream, Mockito.times(1)).close();
+ Mockito.verify(inStream, Mockito.times(1)).close();
Mockito.verify(connHolder).releaseConnection();
}
@@ -69,7 +69,7 @@ public class TestResponseEntityWrapper {
public void testReusableEntityStreamClosedIOError() throws Exception {
Mockito.when(entity.isStreaming()).thenReturn(true);
Mockito.when(connHolder.isReusable()).thenReturn(true);
- Mockito.doThrow(new IOException()).when(instream).close();
+ Mockito.doThrow(new IOException()).when(inStream).close();
try {
EntityUtils.consume(wrapper);
Assert.fail("IOException expected");
@@ -83,28 +83,28 @@ public class TestResponseEntityWrapper {
Mockito.when(entity.isStreaming()).thenReturn(true);
Mockito.when(connHolder.isReusable()).thenReturn(true);
Mockito.when(connHolder.isReleased()).thenReturn(true);
- Mockito.doThrow(new SocketException()).when(instream).close();
+ Mockito.doThrow(new SocketException()).when(inStream).close();
EntityUtils.consume(wrapper);
Mockito.verify(connHolder).close();
}
@Test
public void testReusableEntityWriteTo() throws Exception {
- final OutputStream outstream = Mockito.mock(OutputStream.class);
+ final OutputStream outStream = Mockito.mock(OutputStream.class);
Mockito.when(entity.isStreaming()).thenReturn(true);
Mockito.when(connHolder.isReusable()).thenReturn(true);
- wrapper.writeTo(outstream);
+ wrapper.writeTo(outStream);
Mockito.verify(connHolder).releaseConnection();
}
@Test
public void testReusableEntityWriteToIOError() throws Exception {
- final OutputStream outstream = Mockito.mock(OutputStream.class);
+ final OutputStream outStream = Mockito.mock(OutputStream.class);
Mockito.when(entity.isStreaming()).thenReturn(true);
Mockito.when(connHolder.isReusable()).thenReturn(true);
- Mockito.doThrow(new IOException()).when(entity).writeTo(outstream);
+ Mockito.doThrow(new IOException()).when(entity).writeTo(outStream);
try {
- wrapper.writeTo(outstream);
+ wrapper.writeTo(outStream);
Assert.fail("IOException expected");
} catch (final IOException ex) {
}
@@ -114,21 +114,21 @@ public class TestResponseEntityWrapper {
@Test
public void testReusableEntityEndOfStream() throws Exception {
- Mockito.when(instream.read()).thenReturn(-1);
+ Mockito.when(inStream.read()).thenReturn(-1);
Mockito.when(entity.isStreaming()).thenReturn(true);
Mockito.when(connHolder.isReusable()).thenReturn(true);
final InputStream content = wrapper.getContent();
Assert.assertEquals(-1, content.read());
- Mockito.verify(instream).close();
+ Mockito.verify(inStream).close();
Mockito.verify(connHolder).releaseConnection();
}
@Test
public void testReusableEntityEndOfStreamIOError() throws Exception {
- Mockito.when(instream.read()).thenReturn(-1);
+ Mockito.when(inStream.read()).thenReturn(-1);
Mockito.when(entity.isStreaming()).thenReturn(true);
Mockito.when(connHolder.isReusable()).thenReturn(true);
- Mockito.doThrow(new IOException()).when(instream).close();
+ Mockito.doThrow(new IOException()).when(inStream).close();
final InputStream content = wrapper.getContent();
try {
content.read();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpmime/src/main/java-deprecated/org/apache/http/entity/mime/MultipartEntity.java
----------------------------------------------------------------------
diff --git a/httpmime/src/main/java-deprecated/org/apache/http/entity/mime/MultipartEntity.java b/httpmime/src/main/java-deprecated/org/apache/http/entity/mime/MultipartEntity.java
index 071aa87..dd264ea 100644
--- a/httpmime/src/main/java-deprecated/org/apache/http/entity/mime/MultipartEntity.java
+++ b/httpmime/src/main/java-deprecated/org/apache/http/entity/mime/MultipartEntity.java
@@ -176,8 +176,8 @@ public class MultipartEntity implements HttpEntity {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- getEntity().writeTo(outstream);
+ public void writeTo(final OutputStream outStream) throws IOException {
+ getEntity().writeTo(outStream);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpmime/src/main/java/org/apache/http/entity/mime/MultipartFormEntity.java
----------------------------------------------------------------------
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/MultipartFormEntity.java b/httpmime/src/main/java/org/apache/http/entity/mime/MultipartFormEntity.java
index cabb824..e3afe40 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/MultipartFormEntity.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/MultipartFormEntity.java
@@ -102,15 +102,15 @@ class MultipartFormEntity implements HttpEntity {
} else if (this.contentLength > 25 * 1024) {
throw new ContentTooLongException("Content length is too long: " + this.contentLength);
}
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- writeTo(outstream);
- outstream.flush();
- return new ByteArrayInputStream(outstream.toByteArray());
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ writeTo(outStream);
+ outStream.flush();
+ return new ByteArrayInputStream(outStream.toByteArray());
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- this.multipart.writeTo(outstream);
+ public void writeTo(final OutputStream outStream) throws IOException {
+ this.multipart.writeTo(outStream);
}
}
[2/3] httpcomponents-client 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.) - Remove redund
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java
index ce2a2c9..e069370 100644
--- a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java
+++ b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java
@@ -103,11 +103,7 @@ public final class PublicSuffixMatcher {
return false;
}
final DomainType domainType = map.get(rule);
- if (domainType == null) {
- return false;
- } else {
- return expectedType == null || domainType.equals(expectedType);
- }
+ return domainType == null ? false : expectedType == null || domainType.equals(expectedType);
}
private boolean hasRule(final String rule, final DomainType expectedType) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java b/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
index e24be61..4407f13 100644
--- a/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
+++ b/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
@@ -107,9 +107,8 @@ public final class CookieSpecRegistry implements Lookup<CookieSpecProvider> {
final CookieSpecFactory factory = registeredSpecs.get(name.toLowerCase(Locale.ENGLISH));
if (factory != null) {
return factory.newInstance(params);
- } else {
- throw new IllegalStateException("Unsupported cookie spec: " + name);
}
+ throw new IllegalStateException("Unsupported cookie spec: " + name);
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java b/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java
index 296b15c..a1515df 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java
@@ -159,11 +159,7 @@ public abstract class AuthSchemeBase implements ContextAwareAuthScheme {
@Override
public String toString() {
final String name = getSchemeName();
- if (name != null) {
- return name.toUpperCase(Locale.ROOT);
- } else {
- return super.toString();
- }
+ return name != null ? name.toUpperCase(Locale.ROOT) : super.toString();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
index 1e3c62f..74d0377 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
@@ -152,11 +152,7 @@ public class DigestScheme extends RFC2617Scheme {
@Override
public boolean isComplete() {
final String s = getParameter("stale");
- if ("true".equalsIgnoreCase(s)) {
- return false;
- } else {
- return this.complete;
- }
+ return "true".equalsIgnoreCase(s) ? false : this.complete;
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java b/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
index 1fbc86a..e341a85 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
@@ -120,11 +120,9 @@ public abstract class GGSSchemeBase extends AuthSchemeBase {
}
final GSSContext gssContext = createGSSContext(manager, oid, serverName, gssCredential);
- if (input != null) {
- return gssContext.initSecContext(input, 0, input.length);
- } else {
- return gssContext.initSecContext(new byte[] {}, 0, 0);
- }
+ return input != null
+ ? gssContext.initSecContext(input, 0, input.length)
+ : gssContext.initSecContext(new byte[] {}, 0, 0);
}
GSSContext createGSSContext(
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java b/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java
index 6bc2878..a19bd48 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java
@@ -79,21 +79,20 @@ public class HttpAuthenticator {
authStrategy.authFailed(host, authState.getAuthScheme(), context);
}
return true;
- } else {
- switch (authState.getState()) {
- case CHALLENGED:
- case HANDSHAKE:
- this.log.debug("Authentication succeeded");
- authState.setState(AuthProtocolState.SUCCESS);
- authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
- break;
- case SUCCESS:
- break;
- default:
- authState.setState(AuthProtocolState.UNCHALLENGED);
- }
- return false;
}
+ switch (authState.getState()) {
+ case CHALLENGED:
+ case HANDSHAKE:
+ this.log.debug("Authentication succeeded");
+ authState.setState(AuthProtocolState.SUCCESS);
+ authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
+ break;
+ case SUCCESS:
+ break;
+ default:
+ authState.setState(AuthProtocolState.UNCHALLENGED);
+ }
+ return false;
}
public boolean handleAuthChallenge(
@@ -141,14 +140,12 @@ public class HttpAuthenticator {
authState.reset();
authState.setState(AuthProtocolState.FAILURE);
return false;
- } else {
- authState.setState(AuthProtocolState.HANDSHAKE);
- return true;
}
- } else {
- authState.reset();
- // Retry authentication with a different scheme
+ authState.setState(AuthProtocolState.HANDSHAKE);
+ return true;
}
+ authState.reset();
+ // Retry authentication with a different scheme
}
}
final Queue<AuthOption> authOptions = authStrategy.select(challenges, host, response, context);
@@ -159,9 +156,8 @@ public class HttpAuthenticator {
authState.setState(AuthProtocolState.CHALLENGED);
authState.update(authOptions);
return true;
- } else {
- return false;
}
+ return false;
} catch (final MalformedChallengeException ex) {
if (this.log.isWarnEnabled()) {
this.log.warn("Malformed challenge: " + ex.getMessage());
@@ -209,9 +205,8 @@ public class HttpAuthenticator {
}
}
return;
- } else {
- ensureAuthScheme(authScheme);
}
+ ensureAuthScheme(authScheme);
}
if (authScheme != null) {
try {
@@ -235,11 +230,10 @@ public class HttpAuthenticator {
final Credentials creds,
final HttpRequest request,
final HttpContext context) throws AuthenticationException {
- if (authScheme instanceof ContextAwareAuthScheme) {
- return ((ContextAwareAuthScheme) authScheme).authenticate(creds, request, context);
- } else {
- return authScheme.authenticate(creds, request);
- }
+ return authScheme instanceof ContextAwareAuthScheme
+ ? ((ContextAwareAuthScheme) authScheme).authenticate(creds, request,
+ context)
+ : authScheme.authenticate(creds, request);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
index 1677e77..e642615 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
@@ -209,7 +209,7 @@ final class NTLMEngineImpl implements NTLMEngine {
targetInformation, peerServerCertificate, type1Message, type2Message).getResponse();
}
- private static int readULong(final byte[] src, final int index) throws NTLMEngineException {
+ private static int readULong(final byte[] src, final int index) {
if (src.length < index + 4) {
return 0;
}
@@ -217,14 +217,14 @@ final class NTLMEngineImpl implements NTLMEngine {
| ((src[index + 2] & 0xff) << 16) | ((src[index + 3] & 0xff) << 24);
}
- private static int readUShort(final byte[] src, final int index) throws NTLMEngineException {
+ private static int readUShort(final byte[] src, final int index) {
if (src.length < index + 2) {
return 0;
}
return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8);
}
- private static byte[] readSecurityBuffer(final byte[] src, final int index) throws NTLMEngineException {
+ private static byte[] readSecurityBuffer(final byte[] src, final int index) {
final int length = readUShort(src, index);
final int offset = readULong(src, index + 4);
if (src.length < offset + length) {
@@ -236,7 +236,7 @@ final class NTLMEngineImpl implements NTLMEngine {
}
/** Calculate a challenge block */
- private static byte[] makeRandomChallenge(final Random random) throws NTLMEngineException {
+ private static byte[] makeRandomChallenge(final Random random) {
final byte[] rval = new byte[8];
synchronized (random) {
random.nextBytes(rval);
@@ -245,7 +245,7 @@ final class NTLMEngineImpl implements NTLMEngine {
}
/** Calculate a 16-byte secondary key */
- private static byte[] makeSecondaryKey(final Random random) throws NTLMEngineException {
+ private static byte[] makeSecondaryKey(final Random random) {
final byte[] rval = new byte[16];
synchronized (random) {
random.nextBytes(rval);
@@ -747,8 +747,7 @@ final class NTLMEngineImpl implements NTLMEngine {
* @return The response (either NTLMv2 or LMv2, depending on the client
* data).
*/
- private static byte[] lmv2Response(final byte[] hash, final byte[] challenge, final byte[] clientData)
- throws NTLMEngineException {
+ private static byte[] lmv2Response(final byte[] hash, final byte[] challenge, final byte[] clientData) {
final HMACMD5 hmacMD5 = new HMACMD5(hash);
hmacMD5.update(challenge);
hmacMD5.update(clientData);
@@ -856,17 +855,17 @@ final class NTLMEngineImpl implements NTLMEngine {
sequenceNumber++;
}
- private byte[] encrypt( final byte[] data ) throws NTLMEngineException
+ private byte[] encrypt( final byte[] data )
{
return rc4.update( data );
}
- private byte[] decrypt( final byte[] data ) throws NTLMEngineException
+ private byte[] decrypt( final byte[] data )
{
return rc4.update( data );
}
- private byte[] computeSignature( final byte[] message ) throws NTLMEngineException
+ private byte[] computeSignature( final byte[] message )
{
final byte[] sig = new byte[16];
@@ -892,7 +891,7 @@ final class NTLMEngineImpl implements NTLMEngine {
return sig;
}
- private boolean validateSignature( final byte[] signature, final byte message[] ) throws NTLMEngineException
+ private boolean validateSignature( final byte[] signature, final byte message[] )
{
final byte[] computedSignature = computeSignature( message );
// log.info( "SSSSS validateSignature("+seqNumber+")\n"
@@ -1036,12 +1035,11 @@ final class NTLMEngineImpl implements NTLMEngine {
{
if ((flags & FLAG_REQUEST_UNICODE_ENCODING) == 0) {
return DEFAULT_CHARSET;
- } else {
- if (UNICODE_LITTLE_UNMARKED == null) {
- throw new NTLMEngineException( "Unicode not supported" );
- }
- return UNICODE_LITTLE_UNMARKED;
}
+ if (UNICODE_LITTLE_UNMARKED == null) {
+ throw new NTLMEngineException( "Unicode not supported" );
+ }
+ return UNICODE_LITTLE_UNMARKED;
}
/** Strip dot suffix from a name */
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java b/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java
index 4d163ba..eeffd01 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java
@@ -90,9 +90,8 @@ public class BasicAuthCache implements AuthCache {
return host;
}
return new HttpHost(host.getHostName(), port, host.getSchemeName());
- } else {
- return host;
}
+ return host;
}
@Override
@@ -142,9 +141,8 @@ public class BasicAuthCache implements AuthCache {
}
return null;
}
- } else {
- return null;
}
+ return null;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
index dd5eb4a..33ecf97 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
@@ -138,11 +138,10 @@ public class DefaultHttpRequestRetryHandler implements HttpRequestRetryHandler {
}
if (this.nonRetriableClasses.contains(exception.getClass())) {
return false;
- } else {
- for (final Class<? extends IOException> rejectException : this.nonRetriableClasses) {
- if (rejectException.isInstance(exception)) {
- return false;
- }
+ }
+ for (final Class<? extends IOException> rejectException : this.nonRetriableClasses) {
+ if (rejectException.isInstance(exception)) {
+ return false;
}
}
final HttpClientContext clientContext = HttpClientContext.adapt(context);
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java
index 0e02b29..5d92e5a 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java
@@ -226,11 +226,9 @@ public class DefaultRedirectStrategy implements RedirectStrategy {
return new HttpGet(uri);
} else {
final int status = response.getStatusLine().getStatusCode();
- if (status == HttpStatus.SC_TEMPORARY_REDIRECT) {
- return RequestBuilder.copy(request).setUri(uri).build();
- } else {
- return new HttpGet(uri);
- }
+ return status == HttpStatus.SC_TEMPORARY_REDIRECT
+ ? RequestBuilder.copy(request).setUri(uri).build()
+ : new HttpGet(uri);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java b/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
index 061ae3f..8b099af 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
@@ -105,9 +105,9 @@ public class EntityEnclosingRequestWrapper extends RequestWrapper
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
+ public void writeTo(final OutputStream outStream) throws IOException {
consumed = true;
- super.writeTo(outstream);
+ super.writeTo(outStream);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestFutureTask.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestFutureTask.java b/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestFutureTask.java
index f37cd7a..1bd8090 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestFutureTask.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestFutureTask.java
@@ -82,9 +82,8 @@ public class HttpRequestFutureTask<V> extends FutureTask<V> {
public long endedTime() {
if (isDone()) {
return callable.getEnded();
- } else {
- throw new IllegalStateException("Task is not done yet");
}
+ throw new IllegalStateException("Task is not done yet");
}
/**
@@ -94,9 +93,8 @@ public class HttpRequestFutureTask<V> extends FutureTask<V> {
public long requestDuration() {
if (isDone()) {
return endedTime() - startedTime();
- } else {
- throw new IllegalStateException("Task is not done yet");
}
+ throw new IllegalStateException("Task is not done yet");
}
/**
@@ -105,9 +103,8 @@ public class HttpRequestFutureTask<V> extends FutureTask<V> {
public long taskDuration() {
if (isDone()) {
return endedTime() - scheduledTime();
- } else {
- throw new IllegalStateException("Task is not done yet");
}
+ throw new IllegalStateException("Task is not done yet");
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java b/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java
index 47fb238..749ac7e 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java
@@ -106,9 +106,8 @@ class HttpRequestTaskCallable<V> implements Callable<V> {
metrics.getTasks().increment(started);
metrics.getActiveConnections().decrementAndGet();
}
- } else {
- throw new IllegalStateException("call has been cancelled for request " + request.getURI());
}
+ throw new IllegalStateException("call has been cancelled for request " + request.getURI());
}
public void cancel() {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/IdleConnectionEvictor.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/IdleConnectionEvictor.java b/httpclient/src/main/java/org/apache/http/impl/client/IdleConnectionEvictor.java
index b95b508..40c0ff4 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/IdleConnectionEvictor.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/IdleConnectionEvictor.java
@@ -104,8 +104,8 @@ public final class IdleConnectionEvictor {
return thread.isAlive();
}
- public void awaitTermination(final long time, final TimeUnit tunit) throws InterruptedException {
- thread.join((tunit != null ? tunit : TimeUnit.MILLISECONDS).toMillis(time));
+ public void awaitTermination(final long time, final TimeUnit timeUnit) throws InterruptedException {
+ thread.join((timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS).toMillis(time));
}
static class DefaultThreadFactory implements ThreadFactory {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java b/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
index 20bf060..07eac49 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
@@ -240,8 +240,8 @@ class InternalHttpClient extends CloseableHttpClient implements Configurable {
}
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- connManager.closeIdleConnections(idletime, tunit);
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
+ connManager.closeIdleConnections(idletime, timeUnit);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java b/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java
index 30ce492..585eb9e 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java
@@ -150,8 +150,8 @@ class MinimalHttpClient extends CloseableHttpClient {
}
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- connManager.closeIdleConnections(idletime, tunit);
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
+ connManager.closeIdleConnections(idletime, timeUnit);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java b/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
index 122a859..3ac37f6 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
@@ -142,19 +142,13 @@ public class SystemDefaultCredentialsProvider implements CredentialsProvider {
systemcreds.getUserName(),
new String(systemcreds.getPassword()),
null, domain);
- } else {
- if (AuthSchemes.NTLM.equalsIgnoreCase(authscope.getScheme())) {
- // Domain may be specified in a fully qualified user name
- return new NTCredentials(
- systemcreds.getUserName(),
- new String(systemcreds.getPassword()),
- null, null);
- } else {
- return new UsernamePasswordCredentials(
- systemcreds.getUserName(),
- new String(systemcreds.getPassword()));
- }
}
+ return AuthSchemes.NTLM.equalsIgnoreCase(authscope.getScheme())
+ // Domain may be specified in a fully qualified user name
+ ? new NTCredentials(systemcreds.getUserName(),
+ new String(systemcreds.getPassword()), null, null)
+ : new UsernamePasswordCredentials(systemcreds.getUserName(),
+ new String(systemcreds.getPassword()));
}
}
return null;
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java b/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
index 10aef9f..8119102 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
@@ -200,7 +200,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
}
@Override
- public HttpClientConnection get(final long timeout, final TimeUnit tunit) {
+ public HttpClientConnection get(final long timeout, final TimeUnit timeUnit) {
return BasicHttpClientConnectionManager.this.getConnection(
route, state);
}
@@ -255,7 +255,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
public synchronized void releaseConnection(
final HttpClientConnection conn,
final Object state,
- final long keepalive, final TimeUnit tunit) {
+ final long keepalive, final TimeUnit timeUnit) {
Args.notNull(conn, "Connection");
Asserts.check(conn == this.conn, "Connection not obtained from this manager");
if (this.log.isDebugEnabled()) {
@@ -277,14 +277,14 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
if (this.log.isDebugEnabled()) {
final String s;
if (keepalive > 0) {
- s = "for " + keepalive + " " + tunit;
+ s = "for " + keepalive + " " + timeUnit;
} else {
s = "indefinitely";
}
this.log.debug("Connection can be kept alive " + s);
}
if (keepalive > 0) {
- this.expiry = this.updated + tunit.toMillis(keepalive);
+ this.expiry = this.updated + timeUnit.toMillis(keepalive);
} else {
this.expiry = Long.MAX_VALUE;
}
@@ -343,13 +343,13 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
}
@Override
- public synchronized void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- Args.notNull(tunit, "Time unit");
+ public synchronized void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
+ Args.notNull(timeUnit, "Time unit");
if (this.isShutdown.get()) {
return;
}
if (!this.leased) {
- long time = tunit.toMillis(idletime);
+ long time = timeUnit.toMillis(idletime);
if (time < 0) {
time = 0;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java b/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
index eee9b78..603fd72 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
@@ -49,21 +49,21 @@ class CPool extends AbstractConnPool<HttpRoute, ManagedHttpClientConnection, CPo
private final Log log = LogFactory.getLog(CPool.class);
private final long timeToLive;
- private final TimeUnit tunit;
+ private final TimeUnit timeUnit;
public CPool(
final ConnFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
final int defaultMaxPerRoute, final int maxTotal,
- final long timeToLive, final TimeUnit tunit) {
+ final long timeToLive, final TimeUnit timeUnit) {
super(connFactory, defaultMaxPerRoute, maxTotal);
this.timeToLive = timeToLive;
- this.tunit = tunit;
+ this.timeUnit = timeUnit;
}
@Override
protected CPoolEntry createEntry(final HttpRoute route, final ManagedHttpClientConnection conn) {
final String id = Long.toString(COUNTER.getAndIncrement());
- return new CPoolEntry(this.log, id, route, conn, this.timeToLive, this.tunit);
+ return new CPoolEntry(this.log, id, route, conn, this.timeToLive, this.timeUnit);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java b/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
index cb89d27..bf122c8 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
@@ -52,8 +52,8 @@ class CPoolEntry extends PoolEntry<HttpRoute, ManagedHttpClientConnection> {
final String id,
final HttpRoute route,
final ManagedHttpClientConnection conn,
- final long timeToLive, final TimeUnit tunit) {
- super(id, route, conn, timeToLive, tunit);
+ final long timeToLive, final TimeUnit timeUnit) {
+ super(id, route, conn, timeToLive, timeUnit);
this.log = log;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java b/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
index 8c8f623..23197c2 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
@@ -98,21 +98,13 @@ class CPoolProxy implements ManagedHttpClientConnection, HttpContext {
@Override
public boolean isOpen() {
final CPoolEntry local = this.poolEntry;
- if (local != null) {
- return !local.isClosed();
- } else {
- return false;
- }
+ return local != null ? !local.isClosed() : false;
}
@Override
public boolean isStale() {
final HttpClientConnection conn = getConnection();
- if (conn != null) {
- return conn.isStale();
- } else {
- return true;
- }
+ return conn != null ? conn.isStale() : true;
}
@Override
@@ -203,11 +195,7 @@ class CPoolProxy implements ManagedHttpClientConnection, HttpContext {
@Override
public Object getAttribute(final String id) {
final ManagedHttpClientConnection conn = getValidConnection();
- if (conn instanceof HttpContext) {
- return ((HttpContext) conn).getAttribute(id);
- } else {
- return null;
- }
+ return conn instanceof HttpContext ? ((HttpContext) conn).getAttribute(id) : null;
}
@Override
@@ -221,11 +209,7 @@ class CPoolProxy implements ManagedHttpClientConnection, HttpContext {
@Override
public Object removeAttribute(final String id) {
final ManagedHttpClientConnection conn = getValidConnection();
- if (conn instanceof HttpContext) {
- return ((HttpContext) conn).removeAttribute(id);
- } else {
- return null;
- }
+ return conn instanceof HttpContext ? ((HttpContext) conn).removeAttribute(id) : null;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
index 76af8e8..b84737a 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
@@ -153,11 +153,9 @@ public class DefaultHttpClientConnectionOperator implements HttpClientConnection
} catch (final ConnectException ex) {
if (last) {
final String msg = ex.getMessage();
- if ("Connection timed out".equals(msg)) {
- throw new ConnectTimeoutException(ex, host, addresses);
- } else {
- throw new HttpHostConnectException(ex, host, addresses);
- }
+ throw "Connection timed out".equals(msg)
+ ? new ConnectTimeoutException(ex, host, addresses)
+ : new HttpHostConnectException(ex, host, addresses);
}
} catch (final NoRouteToHostException ex) {
if (last) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java
index 1a74f5e..73e827c 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java
@@ -62,16 +62,16 @@ public class DefaultManagedHttpClientConnection extends DefaultBHttpClientConnec
public DefaultManagedHttpClientConnection(
final String id,
- final int buffersize,
+ 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,
requestWriterFactory, responseParserFactory);
this.id = id;
@@ -80,8 +80,8 @@ public class DefaultManagedHttpClientConnection extends DefaultBHttpClientConnec
public DefaultManagedHttpClientConnection(
final String id,
- final int buffersize) {
- this(id, buffersize, buffersize, null, null, null, null, null, null, null);
+ final int bufferSize) {
+ this(id, bufferSize, bufferSize, null, null, null, null, null, null, null);
}
@Override
@@ -128,11 +128,7 @@ public class DefaultManagedHttpClientConnection extends DefaultBHttpClientConnec
@Override
public SSLSession getSSLSession() {
final Socket socket = super.getSocket();
- if (socket instanceof SSLSocket) {
- return ((SSLSocket) socket).getSession();
- } else {
- return null;
- }
+ return socket instanceof SSLSocket ? ((SSLSocket) socket).getSession() : null;
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
index 3652115..6bc8174 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
@@ -92,11 +92,9 @@ public class DefaultRoutePlanner implements HttpRoutePlanner {
target = host;
}
final boolean secure = target.getSchemeName().equalsIgnoreCase("https");
- if (proxy == null) {
- return new HttpRoute(target, local, secure);
- } else {
- return new HttpRoute(target, local, proxy, secure);
- }
+ return proxy == null
+ ? new HttpRoute(target, local, secure)
+ : new HttpRoute(target, local, proxy, secure);
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java b/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java
index 6d3b34f..24a7ad8 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java
@@ -46,29 +46,29 @@ import org.apache.http.io.HttpMessageWriterFactory;
class LoggingManagedHttpClientConnection extends DefaultManagedHttpClientConnection {
private final Log log;
- private final Log headerlog;
+ private final Log headerLog;
private final Wire wire;
public LoggingManagedHttpClientConnection(
final String id,
final Log log,
- final Log headerlog,
- final Log wirelog,
- final int buffersize,
+ final Log headerLog,
+ final Log wireLog,
+ 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(id, buffersize, fragmentSizeHint, chardecoder, charencoder,
+ super(id, bufferSize, fragmentSizeHint, charDecoder, charEncoder,
constraints, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.log = log;
- this.headerlog = headerlog;
- this.wire = new Wire(wirelog, id);
+ this.headerLog = headerLog;
+ this.wire = new Wire(wireLog, id);
}
@Override
@@ -118,22 +118,22 @@ class LoggingManagedHttpClientConnection extends DefaultManagedHttpClientConnect
@Override
protected void onResponseReceived(final HttpResponse response) {
- if (response != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(getId() + " << " + response.getStatusLine().toString());
+ if (response != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(getId() + " << " + response.getStatusLine().toString());
final Header[] headers = response.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(getId() + " << " + header.toString());
+ this.headerLog.debug(getId() + " << " + header.toString());
}
}
}
@Override
protected void onRequestSubmitted(final HttpRequest request) {
- if (request != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(getId() + " >> " + request.getRequestLine().toString());
+ if (request != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(getId() + " >> " + request.getRequestLine().toString());
final Header[] headers = request.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(getId() + " >> " + header.toString());
+ this.headerLog.debug(getId() + " >> " + header.toString());
}
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java b/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
index 7057c3e..ff40295 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
@@ -63,8 +63,8 @@ public class ManagedHttpClientConnectionFactory
public static final ManagedHttpClientConnectionFactory INSTANCE = new ManagedHttpClientConnectionFactory();
private final Log log = LogFactory.getLog(DefaultManagedHttpClientConnection.class);
- private final Log headerlog = LogFactory.getLog("org.apache.http.headers");
- private final Log wirelog = LogFactory.getLog("org.apache.http.wire");
+ private final Log headerLog = LogFactory.getLog("org.apache.http.headers");
+ private final Log wireLog = LogFactory.getLog("org.apache.http.wire");
private final HttpMessageWriterFactory<HttpRequest> requestWriterFactory;
private final HttpMessageParserFactory<HttpResponse> responseParserFactory;
@@ -108,31 +108,31 @@ public class ManagedHttpClientConnectionFactory
@Override
public ManagedHttpClientConnection create(final HttpRoute route, final ConnectionConfig config) {
final ConnectionConfig cconfig = config != null ? config : ConnectionConfig.DEFAULT;
- CharsetDecoder chardecoder = null;
- CharsetEncoder charencoder = null;
+ CharsetDecoder charDecoder = null;
+ CharsetEncoder charEncoder = null;
final Charset charset = cconfig.getCharset();
final CodingErrorAction malformedInputAction = cconfig.getMalformedInputAction() != null ?
cconfig.getMalformedInputAction() : CodingErrorAction.REPORT;
final CodingErrorAction unmappableInputAction = cconfig.getUnmappableInputAction() != null ?
cconfig.getUnmappableInputAction() : CodingErrorAction.REPORT;
if (charset != null) {
- chardecoder = charset.newDecoder();
- chardecoder.onMalformedInput(malformedInputAction);
- chardecoder.onUnmappableCharacter(unmappableInputAction);
- charencoder = charset.newEncoder();
- charencoder.onMalformedInput(malformedInputAction);
- charencoder.onUnmappableCharacter(unmappableInputAction);
+ charDecoder = charset.newDecoder();
+ charDecoder.onMalformedInput(malformedInputAction);
+ charDecoder.onUnmappableCharacter(unmappableInputAction);
+ charEncoder = charset.newEncoder();
+ charEncoder.onMalformedInput(malformedInputAction);
+ charEncoder.onUnmappableCharacter(unmappableInputAction);
}
final String id = "http-outgoing-" + Long.toString(COUNTER.getAndIncrement());
return new LoggingManagedHttpClientConnection(
id,
log,
- headerlog,
- wirelog,
+ headerLog,
+ wireLog,
cconfig.getBufferSize(),
cconfig.getFragmentSizeHint(),
- chardecoder,
- charencoder,
+ charDecoder,
+ charEncoder,
cconfig.getMessageConstraints(),
incomingContentStrategy,
outgoingContentStrategy,
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java b/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
index b20e024..4c38bd8 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
@@ -121,8 +121,8 @@ public class PoolingHttpClientConnectionManager
this(getDefaultRegistry());
}
- public PoolingHttpClientConnectionManager(final long timeToLive, final TimeUnit tunit) {
- this(getDefaultRegistry(), null, null ,null, timeToLive, tunit);
+ public PoolingHttpClientConnectionManager(final long timeToLive, final TimeUnit timeUnit) {
+ this(getDefaultRegistry(), null, null ,null, timeToLive, timeUnit);
}
public PoolingHttpClientConnectionManager(
@@ -159,11 +159,11 @@ public class PoolingHttpClientConnectionManager
final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
final SchemePortResolver schemePortResolver,
final DnsResolver dnsResolver,
- final long timeToLive, final TimeUnit tunit) {
+ final long timeToLive, final TimeUnit timeUnit) {
this(
new DefaultHttpClientConnectionOperator(socketFactoryRegistry, schemePortResolver, dnsResolver),
connFactory,
- timeToLive, tunit
+ timeToLive, timeUnit
);
}
@@ -173,11 +173,11 @@ public class PoolingHttpClientConnectionManager
public PoolingHttpClientConnectionManager(
final HttpClientConnectionOperator httpClientConnectionOperator,
final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
- final long timeToLive, final TimeUnit tunit) {
+ final long timeToLive, final TimeUnit timeUnit) {
super();
this.configData = new ConfigData();
this.pool = new CPool(new InternalConnectionFactory(
- this.configData, connFactory), 2, 20, timeToLive, tunit);
+ this.configData, connFactory), 2, 20, timeToLive, timeUnit);
this.pool.setValidateAfterInactivity(2000);
this.connectionOperator = Args.notNull(httpClientConnectionOperator, "HttpClientConnectionOperator");
this.isShutDown = new AtomicBoolean(false);
@@ -275,8 +275,8 @@ public class PoolingHttpClientConnectionManager
@Override
public HttpClientConnection get(
final long timeout,
- final TimeUnit tunit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
- final HttpClientConnection conn = leaseConnection(future, timeout, tunit);
+ final TimeUnit timeUnit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
+ final HttpClientConnection conn = leaseConnection(future, timeout, timeUnit);
if (conn.isOpen()) {
final HttpHost host;
if (route.getProxyHost() != null) {
@@ -297,10 +297,10 @@ public class PoolingHttpClientConnectionManager
protected HttpClientConnection leaseConnection(
final Future<CPoolEntry> future,
final long timeout,
- final TimeUnit tunit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
+ final TimeUnit timeUnit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
final CPoolEntry entry;
try {
- entry = future.get(timeout, tunit);
+ entry = future.get(timeout, timeUnit);
if (entry == null || future.isCancelled()) {
throw new InterruptedException();
}
@@ -318,7 +318,7 @@ public class PoolingHttpClientConnectionManager
public void releaseConnection(
final HttpClientConnection managedConn,
final Object state,
- final long keepalive, final TimeUnit tunit) {
+ final long keepalive, final TimeUnit timeUnit) {
Args.notNull(managedConn, "Managed connection");
synchronized (managedConn) {
final CPoolEntry entry = CPoolProxy.detach(managedConn);
@@ -328,7 +328,7 @@ public class PoolingHttpClientConnectionManager
final ManagedHttpClientConnection conn = entry.getConnection();
try {
if (conn.isOpen()) {
- final TimeUnit effectiveUnit = tunit != null ? tunit : TimeUnit.MILLISECONDS;
+ final TimeUnit effectiveUnit = timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS;
entry.setState(state);
entry.updateExpiry(keepalive, effectiveUnit);
if (this.log.isDebugEnabled()) {
@@ -416,11 +416,11 @@ public class PoolingHttpClientConnectionManager
}
@Override
- public void closeIdleConnections(final long idleTimeout, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idleTimeout, final TimeUnit timeUnit) {
if (this.log.isDebugEnabled()) {
- this.log.debug("Closing connections idle longer than " + idleTimeout + " " + tunit);
+ this.log.debug("Closing connections idle longer than " + idleTimeout + " " + timeUnit);
}
- this.pool.closeIdle(idleTimeout, tunit);
+ this.pool.closeIdle(idleTimeout, timeUnit);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java b/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java
index 48195e5..07b2e77 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java
@@ -59,11 +59,11 @@ public class Wire {
this(log, "");
}
- private void wire(final String header, final InputStream instream)
+ private void wire(final String header, final InputStream inStream)
throws IOException {
final StringBuilder buffer = new StringBuilder();
int ch;
- while ((ch = instream.read()) != -1) {
+ while ((ch = inStream.read()) != -1) {
if (ch == 13) {
buffer.append("[\\r]");
} else if (ch == 10) {
@@ -93,16 +93,16 @@ public class Wire {
return log.isDebugEnabled();
}
- public void output(final InputStream outstream)
+ public void output(final InputStream outStream)
throws IOException {
- Args.notNull(outstream, "Output");
- wire(">> ", outstream);
+ Args.notNull(outStream, "Output");
+ wire(">> ", outStream);
}
- public void input(final InputStream instream)
+ public void input(final InputStream inStream)
throws IOException {
- Args.notNull(instream, "Input");
- wire("<< ", instream);
+ Args.notNull(inStream, "Input");
+ wire("<< ", inStream);
}
public void output(final byte[] b, final int off, final int len)
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java
index c291f1c..72770a6 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java
@@ -105,14 +105,14 @@ public class DefaultCookieSpec implements CookieSpec {
final CookieOrigin origin) throws MalformedCookieException {
Args.notNull(header, "Header");
Args.notNull(origin, "Cookie origin");
- HeaderElement[] helems = header.getElements();
+ HeaderElement[] hElems = header.getElements();
boolean versioned = false;
boolean netscape = false;
- for (final HeaderElement helem: helems) {
- if (helem.getParameterByName("version") != null) {
+ for (final HeaderElement hElem: hElems) {
+ if (hElem.getParameterByName("version") != null) {
versioned = true;
}
- if (helem.getParameterByName("expires") != null) {
+ if (hElem.getParameterByName("expires") != null) {
netscape = true;
}
}
@@ -128,23 +128,20 @@ public class DefaultCookieSpec implements CookieSpec {
((FormattedHeader) header).getValuePos(),
buffer.length());
} else {
- final String s = header.getValue();
- if (s == null) {
+ final String hValue = header.getValue();
+ if (hValue == null) {
throw new MalformedCookieException("Header value is null");
}
- buffer = new CharArrayBuffer(s.length());
- buffer.append(s);
+ buffer = new CharArrayBuffer(hValue.length());
+ buffer.append(hValue);
cursor = new ParserCursor(0, buffer.length());
}
- helems = new HeaderElement[] { parser.parseHeader(buffer, cursor) };
- return netscapeDraft.parse(helems, origin);
- } else {
- if (SM.SET_COOKIE2.equals(header.getName())) {
- return strict.parse(helems, origin);
- } else {
- return obsoleteStrict.parse(helems, origin);
- }
+ hElems = new HeaderElement[] { parser.parseHeader(buffer, cursor) };
+ return netscapeDraft.parse(hElems, origin);
}
+ return SM.SET_COOKIE2.equals(header.getName())
+ ? strict.parse(hElems, origin)
+ : obsoleteStrict.parse(hElems, origin);
}
@Override
@@ -169,14 +166,11 @@ public class DefaultCookieSpec implements CookieSpec {
Args.notNull(cookie, "Cookie");
Args.notNull(origin, "Cookie origin");
if (cookie.getVersion() > 0) {
- if (cookie instanceof SetCookie2) {
- return strict.match(cookie, origin);
- } else {
- return obsoleteStrict.match(cookie, origin);
- }
- } else {
- return netscapeDraft.match(cookie, origin);
+ return cookie instanceof SetCookie2
+ ? strict.match(cookie, origin)
+ : obsoleteStrict.match(cookie, origin);
}
+ return netscapeDraft.match(cookie, origin);
}
@Override
@@ -193,14 +187,11 @@ public class DefaultCookieSpec implements CookieSpec {
}
}
if (version > 0) {
- if (isSetCookie2) {
- return strict.formatCookies(cookies);
- } else {
- return obsoleteStrict.formatCookies(cookies);
- }
- } else {
- return netscapeDraft.formatCookies(cookies);
+ return isSetCookie2
+ ? strict.formatCookies(cookies)
+ : obsoleteStrict.formatCookies(cookies);
}
+ return netscapeDraft.formatCookies(cookies);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java
index 8043bb4..02fdbdc 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java
@@ -205,10 +205,9 @@ public class LaxExpiresHandler extends AbstractCookieAttributeHandler implements
final char current = buf.charAt(i);
if (DELIMS.get(current)) {
break;
- } else {
- pos++;
- dst.append(current);
}
+ pos++;
+ dst.append(current);
}
cursor.updatePos(pos);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
index dbc205e..429782e 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
@@ -143,11 +143,7 @@ public class RFC2109Spec extends CookieSpecBase {
} else {
cookieList = cookies;
}
- if (this.oneHeader) {
- return doFormatOneHeader(cookieList);
- } else {
- return doFormatManyHeaders(cookieList);
- }
+ return this.oneHeader ? doFormatOneHeader(cookieList) : doFormatManyHeaders(cookieList);
}
private List<Header> doFormatOneHeader(final List<Cookie> cookies) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
index 5fca006..5b77164 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
@@ -64,7 +64,6 @@ public class RFC2965Spec extends RFC2109Spec {
/**
* Default constructor
- *
*/
public RFC2965Spec() {
this(null, false);
@@ -222,7 +221,7 @@ public class RFC2965Spec extends RFC2109Spec {
* @param origin origin where cookie is received from or being sent to.
*/
private static CookieOrigin adjustEffectiveHost(final CookieOrigin origin) {
- String host = origin.getHost();
+ final String host = origin.getHost();
// Test if the host name appears to be a fully qualified DNS name,
// IPv4 address or IPv6 address
@@ -234,16 +233,13 @@ public class RFC2965Spec extends RFC2109Spec {
break;
}
}
- if (isLocalHost) {
- host += ".local";
- return new CookieOrigin(
- host,
- origin.getPort(),
- origin.getPath(),
- origin.isSecure());
- } else {
- return origin;
- }
+ return isLocalHost
+ ? new CookieOrigin(
+ host + ".local",
+ origin.getPort(),
+ origin.getPath(),
+ origin.isSecure())
+ : origin;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java b/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java
index daa5a31..c102f91 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java
@@ -56,7 +56,7 @@ class ConnectionHolder implements ConnectionReleaseTrigger, Cancellable, Closeab
private volatile boolean reusable;
private volatile Object state;
private volatile long validDuration;
- private volatile TimeUnit tunit;
+ private volatile TimeUnit timeUnit;
public ConnectionHolder(
final Log log,
@@ -85,10 +85,10 @@ class ConnectionHolder implements ConnectionReleaseTrigger, Cancellable, Closeab
this.state = state;
}
- public void setValidFor(final long duration, final TimeUnit tunit) {
+ public void setValidFor(final long duration, final TimeUnit timeUnit) {
synchronized (this.managedConn) {
this.validDuration = duration;
- this.tunit = tunit;
+ this.timeUnit = timeUnit;
}
}
@@ -97,7 +97,7 @@ class ConnectionHolder implements ConnectionReleaseTrigger, Cancellable, Closeab
synchronized (this.managedConn) {
if (reusable) {
this.manager.releaseConnection(this.managedConn,
- this.state, this.validDuration, this.tunit);
+ this.state, this.validDuration, this.timeUnit);
} else {
try {
this.managedConn.close();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java b/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java
index 1affd94..e5bba36 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java
@@ -116,9 +116,9 @@ class RequestEntityProxy implements HttpEntity {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
+ public void writeTo(final OutputStream outStream) throws IOException {
consumed = true;
- original.writeTo(outstream);
+ original.writeTo(outStream);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java b/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java
index 6f53c23..47c5ac9 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java
@@ -94,10 +94,10 @@ class ResponseEntityProxy extends HttpEntityWrapper implements EofSensorWatcher
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
+ public void writeTo(final OutputStream outStream) throws IOException {
try {
- if (outstream != null) {
- this.wrappedEntity.writeTo(outstream);
+ if (outStream != null) {
+ this.wrappedEntity.writeTo(outStream);
}
releaseConnection();
} catch (final IOException ex) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java b/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java
index 10564a0..937acc4 100644
--- a/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java
+++ b/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java
@@ -203,13 +203,13 @@ public class TestCredentials {
public void testUsernamePasswordCredentialsSerialization() throws Exception {
final UsernamePasswordCredentials orig = new UsernamePasswordCredentials("name", "pwd");
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final UsernamePasswordCredentials clone = (UsernamePasswordCredentials) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final UsernamePasswordCredentials clone = (UsernamePasswordCredentials) inStream.readObject();
Assert.assertEquals(orig, clone);
}
@@ -217,13 +217,13 @@ public class TestCredentials {
public void testNTCredentialsSerialization() throws Exception {
final NTCredentials orig = new NTCredentials("name", "pwd", "somehost", "domain");
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final NTCredentials clone = (NTCredentials) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final NTCredentials clone = (NTCredentials) inStream.readObject();
Assert.assertEquals(orig, clone);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/client/entity/TestDecompressingEntity.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/client/entity/TestDecompressingEntity.java b/httpclient/src/test/java/org/apache/http/client/entity/TestDecompressingEntity.java
index 347d99d..b36a609 100644
--- a/httpclient/src/test/java/org/apache/http/client/entity/TestDecompressingEntity.java
+++ b/httpclient/src/test/java/org/apache/http/client/entity/TestDecompressingEntity.java
@@ -97,8 +97,8 @@ public class TestDecompressingEntity {
super(wrapped, new InputStreamFactory() {
@Override
- public InputStream create(final InputStream instream) throws IOException {
- return new CheckedInputStream(instream, checksum);
+ public InputStream create(final InputStream inStream) throws IOException {
+ return new CheckedInputStream(inStream, checksum);
}
});
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java b/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java
index 2f9ba9a..516299d 100644
--- a/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java
+++ b/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java
@@ -41,6 +41,7 @@ import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.Matchers;
import org.mockito.Mockito;
public class TestGZip {
@@ -71,7 +72,7 @@ public class TestGZip {
@Test
public void testCompressionIOExceptionLeavesOutputStreamOpen() throws Exception {
final HttpEntity in = Mockito.mock(HttpEntity.class);
- Mockito.doThrow(new IOException("Ooopsie")).when(in).writeTo(Mockito.<OutputStream>any());
+ Mockito.doThrow(new IOException("Ooopsie")).when(in).writeTo(Matchers.<OutputStream>any());
final GzipCompressingEntity gzipe = new GzipCompressingEntity(in);
final OutputStream out = Mockito.mock(OutputStream.class);
try {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java b/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java
index 51a794e..2165387 100644
--- a/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java
+++ b/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java
@@ -97,8 +97,8 @@ public class TestHttpRequestBase {
@Test(expected=CloneNotSupportedException.class)
public void testCloneStreamingEntityEnclosingRequests() throws Exception {
- final ByteArrayInputStream instream = new ByteArrayInputStream(new byte[] {});
- final InputStreamEntity e2 = new InputStreamEntity(instream, -1);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(new byte[] {});
+ final InputStreamEntity e2 = new InputStreamEntity(inStream, -1);
final HttpPost httppost = new HttpPost("http://host/path");
httppost.setEntity(e2);
httppost.clone();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
index 1c8cf42..4854f52 100644
--- a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
+++ b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
@@ -57,6 +57,7 @@ import org.apache.http.protocol.HttpCoreContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Matchers;
import org.mockito.Mockito;
public class TestRequestAddCookies {
@@ -402,7 +403,7 @@ public class TestRequestAddCookies {
Assert.assertNotNull(headers2);
Assert.assertEquals(0, headers2.length);
- Mockito.verify(this.cookieStore, Mockito.times(1)).clearExpired(Mockito.<Date>any());
+ Mockito.verify(this.cookieStore, Mockito.times(1)).clearExpired(Matchers.<Date>any());
}
@Test
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java b/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java
index b1fa88d..f8d778f 100644
--- a/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java
+++ b/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java
@@ -66,22 +66,22 @@ public class TestHttpClientUtils {
public void testCloseQuietlyResponseEntity() throws Exception {
final HttpResponse response = Mockito.mock(HttpResponse.class);
final HttpEntity entity = Mockito.mock(HttpEntity.class);
- final InputStream instream = Mockito.mock(InputStream.class);
+ final InputStream inStream = Mockito.mock(InputStream.class);
Mockito.when(response.getEntity()).thenReturn(entity);
Mockito.when(entity.isStreaming()).thenReturn(Boolean.TRUE);
- Mockito.when(entity.getContent()).thenReturn(instream);
+ Mockito.when(entity.getContent()).thenReturn(inStream);
HttpClientUtils.closeQuietly(response);
- Mockito.verify(instream).close();
+ Mockito.verify(inStream).close();
}
@Test
public void testCloseQuietlyResponseIgnoreIOError() throws Exception {
final HttpResponse response = Mockito.mock(HttpResponse.class);
final HttpEntity entity = Mockito.mock(HttpEntity.class);
- final InputStream instream = Mockito.mock(InputStream.class);
+ final InputStream inStream = Mockito.mock(InputStream.class);
Mockito.when(response.getEntity()).thenReturn(entity);
- Mockito.when(entity.getContent()).thenReturn(instream);
- Mockito.doThrow(new IOException()).when(instream).close();
+ Mockito.when(entity.getContent()).thenReturn(inStream);
+ Mockito.doThrow(new IOException()).when(inStream).close();
HttpClientUtils.closeQuietly(response);
}
@@ -114,12 +114,12 @@ public class TestHttpClientUtils {
public void testCloseQuietlyCloseableResponseEntity() throws Exception {
final CloseableHttpResponse response = Mockito.mock(CloseableHttpResponse.class);
final HttpEntity entity = Mockito.mock(HttpEntity.class);
- final InputStream instream = Mockito.mock(InputStream.class);
+ final InputStream inStream = Mockito.mock(InputStream.class);
Mockito.when(response.getEntity()).thenReturn(entity);
Mockito.when(entity.isStreaming()).thenReturn(Boolean.TRUE);
- Mockito.when(entity.getContent()).thenReturn(instream);
+ Mockito.when(entity.getContent()).thenReturn(inStream);
HttpClientUtils.closeQuietly(response);
- Mockito.verify(instream).close();
+ Mockito.verify(inStream).close();
Mockito.verify(response).close();
}
@@ -127,10 +127,10 @@ public class TestHttpClientUtils {
public void testCloseQuietlyCloseableResponseIgnoreIOError() throws Exception {
final CloseableHttpResponse response = Mockito.mock(CloseableHttpResponse.class);
final HttpEntity entity = Mockito.mock(HttpEntity.class);
- final InputStream instream = Mockito.mock(InputStream.class);
+ final InputStream inStream = Mockito.mock(InputStream.class);
Mockito.when(response.getEntity()).thenReturn(entity);
- Mockito.when(entity.getContent()).thenReturn(instream);
- Mockito.doThrow(new IOException()).when(instream).close();
+ Mockito.when(entity.getContent()).thenReturn(inStream);
+ Mockito.doThrow(new IOException()).when(inStream).close();
HttpClientUtils.closeQuietly(response);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/conn/TestEofSensorInputStream.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/conn/TestEofSensorInputStream.java b/httpclient/src/test/java/org/apache/http/conn/TestEofSensorInputStream.java
index 396f431..7770e77 100644
--- a/httpclient/src/test/java/org/apache/http/conn/TestEofSensorInputStream.java
+++ b/httpclient/src/test/java/org/apache/http/conn/TestEofSensorInputStream.java
@@ -37,15 +37,15 @@ import org.mockito.Mockito;
@SuppressWarnings({"boxing","static-access"}) // test code
public class TestEofSensorInputStream {
- private InputStream instream;
+ private InputStream inStream;
private EofSensorWatcher eofwatcher;
private EofSensorInputStream eofstream;
@Before
public void setup() throws Exception {
- instream = Mockito.mock(InputStream.class);
+ inStream = Mockito.mock(InputStream.class);
eofwatcher = Mockito.mock(EofSensorWatcher.class);
- eofstream = new EofSensorInputStream(instream, eofwatcher);
+ eofstream = new EofSensorInputStream(inStream, eofwatcher);
}
@Test
@@ -57,8 +57,8 @@ public class TestEofSensorInputStream {
Assert.assertTrue(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(instream, Mockito.times(1)).close();
- Mockito.verify(eofwatcher).streamClosed(instream);
+ Mockito.verify(inStream, Mockito.times(1)).close();
+ Mockito.verify(eofwatcher).streamClosed(inStream);
eofstream.close();
}
@@ -75,7 +75,7 @@ public class TestEofSensorInputStream {
Assert.assertTrue(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(eofwatcher).streamClosed(instream);
+ Mockito.verify(eofwatcher).streamClosed(inStream);
}
@Test
@@ -87,8 +87,8 @@ public class TestEofSensorInputStream {
Assert.assertTrue(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(instream, Mockito.times(1)).close();
- Mockito.verify(eofwatcher).streamClosed(instream);
+ Mockito.verify(inStream, Mockito.times(1)).close();
+ Mockito.verify(eofwatcher).streamClosed(inStream);
eofstream.releaseConnection();
}
@@ -102,8 +102,8 @@ public class TestEofSensorInputStream {
Assert.assertTrue(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(instream, Mockito.times(1)).close();
- Mockito.verify(eofwatcher).streamAbort(instream);
+ Mockito.verify(inStream, Mockito.times(1)).close();
+ Mockito.verify(eofwatcher).streamAbort(inStream);
eofstream.abortConnection();
}
@@ -120,28 +120,28 @@ public class TestEofSensorInputStream {
Assert.assertTrue(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(eofwatcher).streamAbort(instream);
+ Mockito.verify(eofwatcher).streamAbort(inStream);
}
@Test
public void testRead() throws Exception {
Mockito.when(eofwatcher.eofDetected(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
- Mockito.when(instream.read()).thenReturn(0, -1);
+ Mockito.when(inStream.read()).thenReturn(0, -1);
Assert.assertEquals(0, eofstream.read());
Assert.assertFalse(eofstream.isSelfClosed());
Assert.assertNotNull(eofstream.getWrappedStream());
- Mockito.verify(eofwatcher, Mockito.never()).eofDetected(instream);
+ Mockito.verify(eofwatcher, Mockito.never()).eofDetected(inStream);
Assert.assertEquals(-1, eofstream.read());
Assert.assertFalse(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(instream, Mockito.times(1)).close();
- Mockito.verify(eofwatcher).eofDetected(instream);
+ Mockito.verify(inStream, Mockito.times(1)).close();
+ Mockito.verify(eofwatcher).eofDetected(inStream);
Assert.assertEquals(-1, eofstream.read());
}
@@ -149,7 +149,7 @@ public class TestEofSensorInputStream {
@Test
public void testReadIOError() throws Exception {
Mockito.when(eofwatcher.eofDetected(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
- Mockito.when(instream.read()).thenThrow(new IOException());
+ Mockito.when(inStream.read()).thenThrow(new IOException());
try {
eofstream.read();
@@ -159,13 +159,13 @@ public class TestEofSensorInputStream {
Assert.assertFalse(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(eofwatcher).streamAbort(instream);
+ Mockito.verify(eofwatcher).streamAbort(inStream);
}
@Test
public void testReadByteArray() throws Exception {
Mockito.when(eofwatcher.eofDetected(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
- Mockito.when(instream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
+ Mockito.when(inStream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
.thenReturn(1, -1);
final byte[] tmp = new byte[1];
@@ -175,15 +175,15 @@ public class TestEofSensorInputStream {
Assert.assertFalse(eofstream.isSelfClosed());
Assert.assertNotNull(eofstream.getWrappedStream());
- Mockito.verify(eofwatcher, Mockito.never()).eofDetected(instream);
+ Mockito.verify(eofwatcher, Mockito.never()).eofDetected(inStream);
Assert.assertEquals(-1, eofstream.read(tmp));
Assert.assertFalse(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(instream, Mockito.times(1)).close();
- Mockito.verify(eofwatcher).eofDetected(instream);
+ Mockito.verify(inStream, Mockito.times(1)).close();
+ Mockito.verify(eofwatcher).eofDetected(inStream);
Assert.assertEquals(-1, eofstream.read(tmp));
}
@@ -191,7 +191,7 @@ public class TestEofSensorInputStream {
@Test
public void testReadByteArrayIOError() throws Exception {
Mockito.when(eofwatcher.eofDetected(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
- Mockito.when(instream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
+ Mockito.when(inStream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
.thenThrow(new IOException());
final byte[] tmp = new byte[1];
@@ -203,7 +203,7 @@ public class TestEofSensorInputStream {
Assert.assertFalse(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(eofwatcher).streamAbort(instream);
+ Mockito.verify(eofwatcher).streamAbort(inStream);
}
@Test
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java b/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java
index d8a4c3d..299e191 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java
@@ -85,11 +85,7 @@ public final class MockConnPoolControl implements ConnPoolControl<HttpRoute> {
@Override
public int getMaxPerRoute(final HttpRoute route) {
final Integer max = this.maxPerHostMap.get(route);
- if (max != null) {
- return max.intValue();
- } else {
- return this.defaultMax;
- }
+ return max != null ? max.intValue() : this.defaultMax;
}
public void setMaxForRoutes(final Map<HttpRoute, Integer> map) {
[3/3] httpcomponents-client 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.) - Remove redund
Posted by ol...@apache.org.
- 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.)
- Remove redundant superinterface
- Access static methods directly
- Better local var names.
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/commit/e6c226d5
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/tree/e6c226d5
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/diff/e6c226d5
Branch: refs/heads/4.5.x
Commit: e6c226d5f6f34db4bd86aa81168289ac81a0896a
Parents: b9a286e
Author: Gary Gregory <ga...@gmail.com>
Authored: Mon Aug 13 16:47:47 2018 -0600
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Tue Aug 14 20:54:41 2018 +0200
----------------------------------------------------------------------
.../client/fluent/InternalByteArrayEntity.java | 8 +--
.../http/client/fluent/InternalFileEntity.java | 14 +++---
.../fluent/InternalInputStreamEntity.java | 26 +++++-----
.../org/apache/http/client/fluent/Request.java | 8 +--
.../http/client/cache/ResourceFactory.java | 4 +-
.../http/impl/client/cache/CacheEntity.java | 10 ++--
.../http/impl/client/cache/CombinedEntity.java | 16 +++---
.../impl/client/cache/FileResourceFactory.java | 10 ++--
.../impl/client/cache/HeapResourceFactory.java | 16 +++---
.../apache/http/impl/client/cache/IOUtils.java | 6 +--
.../client/cache/SizeLimitedResponseReader.java | 10 ++--
.../impl/client/cache/TestCombinedEntity.java | 4 +-
.../client/ClientConnectionRelease.java | 6 +--
.../apache/http/conn/BasicManagedEntity.java | 4 +-
.../impl/conn/BasicClientConnectionManager.java | 14 +++---
.../http/impl/conn/DefaultClientConnection.java | 16 +++---
.../org/apache/http/impl/conn/HttpConnPool.java | 8 +--
.../apache/http/impl/conn/HttpPoolEntry.java | 4 +-
.../impl/conn/LoggingSessionInputBuffer.java | 34 ++++++-------
.../conn/PoolingClientConnectionManager.java | 28 +++++------
.../http/impl/conn/SingleClientConnManager.java | 8 +--
.../http/impl/conn/tsccm/AbstractConnPool.java | 14 +++---
.../http/impl/conn/tsccm/ConnPoolByRoute.java | 20 ++++----
.../http/impl/conn/tsccm/PoolEntryRequest.java | 4 +-
.../conn/tsccm/ThreadSafeClientConnManager.java | 10 ++--
.../apache/http/auth/AuthSchemeRegistry.java | 3 +-
.../http/client/entity/DecompressingEntity.java | 15 +++---
.../client/entity/GzipCompressingEntity.java | 6 +--
.../http/client/entity/InputStreamFactory.java | 2 +-
.../http/client/methods/HttpRequestWrapper.java | 9 ++--
.../http/client/protocol/HttpClientContext.java | 8 ++-
.../apache/http/client/utils/CloneUtils.java | 6 +--
.../apache/http/client/utils/URIBuilder.java | 8 ++-
.../org/apache/http/client/utils/URIUtils.java | 18 ++-----
.../http/client/utils/URLEncodedUtils.java | 8 +--
.../http/conn/ClientConnectionManager.java | 4 +-
.../http/conn/ClientConnectionRequest.java | 4 +-
.../org/apache/http/conn/ConnectionRequest.java | 4 +-
.../apache/http/conn/EofSensorInputStream.java | 16 +++---
.../http/conn/HttpClientConnectionManager.java | 4 +-
.../http/conn/ManagedClientConnection.java | 3 +-
.../org/apache/http/conn/routing/HttpRoute.java | 24 +++------
.../org/apache/http/conn/scheme/Scheme.java | 14 ++----
.../conn/scheme/SchemeSocketFactoryAdaptor.java | 8 ++-
.../http/conn/scheme/SocketFactoryAdaptor.java | 8 ++-
.../apache/http/conn/ssl/AbstractVerifier.java | 3 +-
.../conn/ssl/SSLConnectionSocketFactory.java | 3 +-
.../http/conn/util/PublicSuffixMatcher.java | 6 +--
.../apache/http/cookie/CookieSpecRegistry.java | 3 +-
.../apache/http/impl/auth/AuthSchemeBase.java | 6 +--
.../org/apache/http/impl/auth/DigestScheme.java | 6 +--
.../apache/http/impl/auth/GGSSchemeBase.java | 8 ++-
.../http/impl/auth/HttpAuthenticator.java | 52 +++++++++-----------
.../apache/http/impl/auth/NTLMEngineImpl.java | 30 ++++++-----
.../apache/http/impl/client/BasicAuthCache.java | 6 +--
.../client/DefaultHttpRequestRetryHandler.java | 9 ++--
.../impl/client/DefaultRedirectStrategy.java | 8 ++-
.../client/EntityEnclosingRequestWrapper.java | 4 +-
.../http/impl/client/HttpRequestFutureTask.java | 9 ++--
.../impl/client/HttpRequestTaskCallable.java | 3 +-
.../http/impl/client/IdleConnectionEvictor.java | 4 +-
.../http/impl/client/InternalHttpClient.java | 4 +-
.../http/impl/client/MinimalHttpClient.java | 4 +-
.../SystemDefaultCredentialsProvider.java | 18 +++----
.../conn/BasicHttpClientConnectionManager.java | 14 +++---
.../java/org/apache/http/impl/conn/CPool.java | 8 +--
.../org/apache/http/impl/conn/CPoolEntry.java | 4 +-
.../org/apache/http/impl/conn/CPoolProxy.java | 24 ++-------
.../DefaultHttpClientConnectionOperator.java | 8 ++-
.../DefaultManagedHttpClientConnection.java | 18 +++----
.../http/impl/conn/DefaultRoutePlanner.java | 8 ++-
.../LoggingManagedHttpClientConnection.java | 30 +++++------
.../ManagedHttpClientConnectionFactory.java | 28 +++++------
.../PoolingHttpClientConnectionManager.java | 30 +++++------
.../java/org/apache/http/impl/conn/Wire.java | 16 +++---
.../http/impl/cookie/DefaultCookieSpec.java | 51 ++++++++-----------
.../http/impl/cookie/LaxExpiresHandler.java | 5 +-
.../apache/http/impl/cookie/RFC2109Spec.java | 6 +--
.../apache/http/impl/cookie/RFC2965Spec.java | 20 +++-----
.../http/impl/execchain/ConnectionHolder.java | 8 +--
.../http/impl/execchain/RequestEntityProxy.java | 4 +-
.../impl/execchain/ResponseEntityProxy.java | 6 +--
.../org/apache/http/auth/TestCredentials.java | 24 ++++-----
.../client/entity/TestDecompressingEntity.java | 4 +-
.../org/apache/http/client/entity/TestGZip.java | 3 +-
.../client/methods/TestHttpRequestBase.java | 4 +-
.../client/protocol/TestRequestAddCookies.java | 3 +-
.../http/client/utils/TestHttpClientUtils.java | 24 ++++-----
.../http/conn/TestEofSensorInputStream.java | 46 ++++++++---------
.../http/impl/client/MockConnPoolControl.java | 6 +--
.../client/TestAbstractResponseHandler.java | 6 +--
.../http/impl/client/TestBasicCookieStore.java | 28 +++++------
.../impl/client/TestBasicResponseHandler.java | 6 +--
.../impl/client/TestIdleConnectionEvictor.java | 3 +-
.../client/integration/TestAbortHandling.java | 15 +++---
.../integration/TestConnectionAutoRelease.java | 6 +--
.../TestMalformedServerResponse.java | 4 +-
.../http/impl/conn/SessionInputBufferMock.java | 26 +++++-----
.../conn/TestDefaultHttpResponseParser.java | 16 +++---
.../http/impl/cookie/TestBasicClientCookie.java | 12 ++---
.../impl/cookie/TestBasicClientCookie2.java | 12 ++---
.../http/impl/cookie/TestRFC6265CookieSpec.java | 13 ++---
.../http/impl/execchain/TestMainClientExec.java | 42 ++++++++--------
.../http/impl/execchain/TestRedirectExec.java | 18 +++----
.../execchain/TestResponseEntityWrapper.java | 30 +++++------
.../http/entity/mime/MultipartEntity.java | 4 +-
.../http/entity/mime/MultipartFormEntity.java | 12 ++---
107 files changed, 599 insertions(+), 716 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java
----------------------------------------------------------------------
diff --git a/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java b/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java
index b2702d1..986095f 100644
--- a/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java
+++ b/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java
@@ -91,10 +91,10 @@ class InternalByteArrayEntity extends AbstractHttpEntity implements Cloneable {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- outstream.write(this.b, this.off, this.len);
- outstream.flush();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ outStream.write(this.b, this.off, this.len);
+ outStream.flush();
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalFileEntity.java
----------------------------------------------------------------------
diff --git a/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalFileEntity.java b/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalFileEntity.java
index 39c2b44..6681e5a 100644
--- a/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalFileEntity.java
+++ b/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalFileEntity.java
@@ -65,18 +65,18 @@ class InternalFileEntity extends AbstractHttpEntity implements Cloneable {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = new FileInputStream(this.file);
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final InputStream inStream = new FileInputStream(this.file);
try {
final byte[] tmp = new byte[4096];
int l;
- while ((l = instream.read(tmp)) != -1) {
- outstream.write(tmp, 0, l);
+ while ((l = inStream.read(tmp)) != -1) {
+ outStream.write(tmp, 0, l);
}
- outstream.flush();
+ outStream.flush();
} finally {
- instream.close();
+ inStream.close();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java
----------------------------------------------------------------------
diff --git a/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java b/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java
index 3a47041..701277a 100644
--- a/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java
+++ b/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java
@@ -40,9 +40,9 @@ class InternalInputStreamEntity extends AbstractHttpEntity {
private final InputStream content;
private final long length;
- public InternalInputStreamEntity(final InputStream instream, final long length, final ContentType contentType) {
+ public InternalInputStreamEntity(final InputStream inputStream, final long length, final ContentType contentType) {
super();
- this.content = Args.notNull(instream, "Source input stream");
+ this.content = Args.notNull(inputStream, "Source input stream");
this.length = length;
if (contentType != null) {
setContentType(contentType.toString());
@@ -65,31 +65,31 @@ class InternalInputStreamEntity extends AbstractHttpEntity {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = this.content;
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final InputStream inStream = this.content;
try {
final byte[] buffer = new byte[4096];
- int l;
+ int readLen;
if (this.length < 0) {
// consume until EOF
- while ((l = instream.read(buffer)) != -1) {
- outstream.write(buffer, 0, l);
+ while ((readLen = inStream.read(buffer)) != -1) {
+ outStream.write(buffer, 0, readLen);
}
} else {
// consume no more than length
long remaining = this.length;
while (remaining > 0) {
- l = instream.read(buffer, 0, (int)Math.min(4096, remaining));
- if (l == -1) {
+ readLen = inStream.read(buffer, 0, (int)Math.min(4096, remaining));
+ if (readLen == -1) {
break;
}
- outstream.write(buffer, 0, l);
- remaining -= l;
+ outStream.write(buffer, 0, readLen);
+ remaining -= readLen;
}
}
} finally {
- instream.close();
+ inStream.close();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java
----------------------------------------------------------------------
diff --git a/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java b/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java
index 4c43f59..4d21166 100644
--- a/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java
+++ b/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java
@@ -401,12 +401,12 @@ public class Request {
return body(new InternalByteArrayEntity(b, off, len, contentType));
}
- public Request bodyStream(final InputStream instream) {
- return body(new InternalInputStreamEntity(instream, -1, null));
+ public Request bodyStream(final InputStream inStream) {
+ return body(new InternalInputStreamEntity(inStream, -1, null));
}
- public Request bodyStream(final InputStream instream, final ContentType contentType) {
- return body(new InternalInputStreamEntity(instream, -1, contentType));
+ public Request bodyStream(final InputStream inStream, final ContentType contentType) {
+ return body(new InternalInputStreamEntity(inStream, -1, contentType));
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient-cache/src/main/java/org/apache/http/client/cache/ResourceFactory.java
----------------------------------------------------------------------
diff --git a/httpclient-cache/src/main/java/org/apache/http/client/cache/ResourceFactory.java b/httpclient-cache/src/main/java/org/apache/http/client/cache/ResourceFactory.java
index 0966479..96a7225 100644
--- a/httpclient-cache/src/main/java/org/apache/http/client/cache/ResourceFactory.java
+++ b/httpclient-cache/src/main/java/org/apache/http/client/cache/ResourceFactory.java
@@ -41,7 +41,7 @@ public interface ResourceFactory {
* Creates a {@link Resource} from a given response body.
* @param requestId a unique identifier for this particular
* response body
- * @param instream the original {@link InputStream}
+ * @param inStream the original {@link InputStream}
* containing the response body of the origin HTTP response.
* @param limit maximum number of bytes to consume of the
* response body; if this limit is reached before the
@@ -52,7 +52,7 @@ public interface ResourceFactory {
* the response body was successfully read.
* @throws IOException
*/
- Resource generate(String requestId, InputStream instream, InputLimit limit) throws IOException;
+ Resource generate(String requestId, InputStream inStream, InputLimit limit) throws IOException;
/**
* Clones an existing {@link Resource}.
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntity.java
----------------------------------------------------------------------
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntity.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntity.java
index 529d698..9a9bb04 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntity.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntity.java
@@ -82,13 +82,13 @@ class CacheEntity implements HttpEntity, Serializable {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = this.cacheEntry.getResource().getInputStream();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final InputStream inStream = this.cacheEntry.getResource().getInputStream();
try {
- IOUtils.copy(instream, outstream);
+ IOUtils.copy(inStream, outStream);
} finally {
- instream.close();
+ inStream.close();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CombinedEntity.java
----------------------------------------------------------------------
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CombinedEntity.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CombinedEntity.java
index c665339..2a8f5fa 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CombinedEntity.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CombinedEntity.java
@@ -41,11 +41,11 @@ class CombinedEntity extends AbstractHttpEntity {
private final Resource resource;
private final InputStream combinedStream;
- CombinedEntity(final Resource resource, final InputStream instream) throws IOException {
+ CombinedEntity(final Resource resource, final InputStream inStream) throws IOException {
super();
this.resource = resource;
this.combinedStream = new SequenceInputStream(
- new ResourceStream(resource.getInputStream()), instream);
+ new ResourceStream(resource.getInputStream()), inStream);
}
@Override
@@ -69,17 +69,17 @@ class CombinedEntity extends AbstractHttpEntity {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = getContent();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final InputStream inStream = getContent();
try {
int l;
final byte[] tmp = new byte[2048];
- while ((l = instream.read(tmp)) != -1) {
- outstream.write(tmp, 0, l);
+ while ((l = inStream.read(tmp)) != -1) {
+ outStream.write(tmp, 0, l);
}
} finally {
- instream.close();
+ inStream.close();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResourceFactory.java
----------------------------------------------------------------------
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResourceFactory.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResourceFactory.java
index b530eab..b4bdbb6 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResourceFactory.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResourceFactory.java
@@ -73,16 +73,16 @@ public class FileResourceFactory implements ResourceFactory {
@Override
public Resource generate(
final String requestId,
- final InputStream instream,
+ final InputStream inStream,
final InputLimit limit) throws IOException {
final File file = generateUniqueCacheFile(requestId);
- final FileOutputStream outstream = new FileOutputStream(file);
+ final FileOutputStream outStream = new FileOutputStream(file);
try {
final byte[] buf = new byte[2048];
long total = 0;
int l;
- while ((l = instream.read(buf)) != -1) {
- outstream.write(buf, 0, l);
+ while ((l = inStream.read(buf)) != -1) {
+ outStream.write(buf, 0, l);
total += l;
if (limit != null && total > limit.getValue()) {
limit.reached();
@@ -90,7 +90,7 @@ public class FileResourceFactory implements ResourceFactory {
}
}
} finally {
- outstream.close();
+ outStream.close();
}
return new FileResource(file);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java
----------------------------------------------------------------------
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java
index 8cb9a2d..e00526e 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java
@@ -47,21 +47,21 @@ public class HeapResourceFactory implements ResourceFactory {
@Override
public Resource generate(
final String requestId,
- final InputStream instream,
+ final InputStream inStream,
final InputLimit limit) throws IOException {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
final byte[] buf = new byte[2048];
long total = 0;
int l;
- while ((l = instream.read(buf)) != -1) {
- outstream.write(buf, 0, l);
+ while ((l = inStream.read(buf)) != -1) {
+ outStream.write(buf, 0, l);
total += l;
if (limit != null && total > limit.getValue()) {
limit.reached();
break;
}
}
- return createResource(outstream.toByteArray());
+ return createResource(outStream.toByteArray());
}
@Override
@@ -72,9 +72,9 @@ public class HeapResourceFactory implements ResourceFactory {
if (resource instanceof HeapResource) {
body = ((HeapResource) resource).getByteArray();
} else {
- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
- IOUtils.copyAndClose(resource.getInputStream(), outstream);
- body = outstream.toByteArray();
+ final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ IOUtils.copyAndClose(resource.getInputStream(), outStream);
+ body = outStream.toByteArray();
}
return createResource(body);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java
----------------------------------------------------------------------
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java
index 229bce6..f4d6325 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java
@@ -43,9 +43,9 @@ class IOUtils {
return;
}
if (entity.isStreaming()) {
- final InputStream instream = entity.getContent();
- if (instream != null) {
- instream.close();
+ final InputStream inStream = entity.getContent();
+ if (inStream != null) {
+ inStream.close();
}
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/SizeLimitedResponseReader.java
----------------------------------------------------------------------
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/SizeLimitedResponseReader.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/SizeLimitedResponseReader.java
index f02e608..d7749ef 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/SizeLimitedResponseReader.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/SizeLimitedResponseReader.java
@@ -49,7 +49,7 @@ class SizeLimitedResponseReader {
private final HttpRequest request;
private final CloseableHttpResponse response;
- private InputStream instream;
+ private InputStream inStream;
private InputLimit limit;
private Resource resource;
private boolean consumed;
@@ -99,12 +99,12 @@ class SizeLimitedResponseReader {
return;
}
final String uri = request.getRequestLine().getUri();
- instream = entity.getContent();
+ inStream = entity.getContent();
try {
- resource = resourceFactory.generate(uri, instream, limit);
+ resource = resourceFactory.generate(uri, inStream, limit);
} finally {
if (!limit.isReached()) {
- instream.close();
+ inStream.close();
}
}
}
@@ -124,7 +124,7 @@ class SizeLimitedResponseReader {
final HttpResponse reconstructed = new BasicHttpResponse(response.getStatusLine());
reconstructed.setHeaders(response.getAllHeaders());
- final CombinedEntity combinedEntity = new CombinedEntity(resource, instream);
+ final CombinedEntity combinedEntity = new CombinedEntity(resource, inStream);
final HttpEntity entity = response.getEntity();
if (entity != null) {
combinedEntity.setContentType(entity.getContentType());
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCombinedEntity.java
----------------------------------------------------------------------
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCombinedEntity.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCombinedEntity.java
index 2e728bd..b58ab63 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCombinedEntity.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCombinedEntity.java
@@ -45,8 +45,8 @@ public class TestCombinedEntity {
when(resource.getInputStream()).thenReturn(
new ByteArrayInputStream(new byte[] { 1, 2, 3, 4, 5 }));
- final ByteArrayInputStream instream = new ByteArrayInputStream(new byte[] { 6, 7, 8, 9, 10 });
- final CombinedEntity entity = new CombinedEntity(resource, instream);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(new byte[] { 6, 7, 8, 9, 10 });
+ final CombinedEntity entity = new CombinedEntity(resource, inStream);
Assert.assertEquals(-1, entity.getContentLength());
Assert.assertFalse(entity.isRepeatable());
Assert.assertTrue(entity.isStreaming());
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
----------------------------------------------------------------------
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java b/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
index 65ee4bf..39b4c5d 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
@@ -59,9 +59,9 @@ public class ClientConnectionRelease {
// If the response does not enclose an entity, there is no need
// to bother about connection release
if (entity != null) {
- InputStream instream = entity.getContent();
+ InputStream inStream = entity.getContent();
try {
- instream.read();
+ inStream.read();
// do something useful with the response
} catch (IOException ex) {
// In case of an IOException the connection will be released
@@ -69,7 +69,7 @@ public class ClientConnectionRelease {
throw ex;
} finally {
// Closing the input stream will trigger connection release
- instream.close();
+ inStream.close();
}
}
} finally {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java-deprecated/org/apache/http/conn/BasicManagedEntity.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/conn/BasicManagedEntity.java b/httpclient/src/main/java-deprecated/org/apache/http/conn/BasicManagedEntity.java
index 93765e7..6f5fc89 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/conn/BasicManagedEntity.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/conn/BasicManagedEntity.java
@@ -113,8 +113,8 @@ public class BasicManagedEntity extends HttpEntityWrapper
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- super.writeTo(outstream);
+ public void writeTo(final OutputStream outStream) throws IOException {
+ super.writeTo(outStream);
ensureConsumed();
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/BasicClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/BasicClientConnectionManager.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/BasicClientConnectionManager.java
index 3e158ab..4a70eff 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/BasicClientConnectionManager.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/BasicClientConnectionManager.java
@@ -141,7 +141,7 @@ public class BasicClientConnectionManager implements ClientConnectionManager {
@Override
public ManagedClientConnection getConnection(
- final long timeout, final TimeUnit tunit) {
+ final long timeout, final TimeUnit timeUnit) {
return BasicClientConnectionManager.this.getConnection(
route, state);
}
@@ -191,7 +191,7 @@ public class BasicClientConnectionManager implements ClientConnectionManager {
}
@Override
- public void releaseConnection(final ManagedClientConnection conn, final long keepalive, final TimeUnit tunit) {
+ public void releaseConnection(final ManagedClientConnection conn, final long keepalive, final TimeUnit timeUnit) {
Args.check(conn instanceof ManagedClientConnectionImpl, "Connection class mismatch, " +
"connection not obtained from this manager");
final ManagedClientConnectionImpl managedConn = (ManagedClientConnectionImpl) conn;
@@ -214,11 +214,11 @@ public class BasicClientConnectionManager implements ClientConnectionManager {
shutdownConnection(managedConn);
}
if (managedConn.isMarkedReusable()) {
- this.poolEntry.updateExpiry(keepalive, tunit != null ? tunit : TimeUnit.MILLISECONDS);
+ this.poolEntry.updateExpiry(keepalive, timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS);
if (this.log.isDebugEnabled()) {
final String s;
if (keepalive > 0) {
- s = "for " + keepalive + " " + tunit;
+ s = "for " + keepalive + " " + timeUnit;
} else {
s = "indefinitely";
}
@@ -249,11 +249,11 @@ public class BasicClientConnectionManager implements ClientConnectionManager {
}
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- Args.notNull(tunit, "Time unit");
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
+ Args.notNull(timeUnit, "Time unit");
synchronized (this) {
assertNotShutdown();
- long time = tunit.toMillis(idletime);
+ long time = timeUnit.toMillis(idletime);
if (time < 0) {
time = 0;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultClientConnection.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultClientConnection.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultClientConnection.java
index 081f067..027a1f2 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultClientConnection.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/DefaultClientConnection.java
@@ -187,29 +187,29 @@ public class DefaultClientConnection extends SocketHttpClientConnection
@Override
protected SessionInputBuffer createSessionInputBuffer(
final Socket socket,
- final int buffersize,
+ final int bufferSize,
final HttpParams params) throws IOException {
- SessionInputBuffer inbuffer = super.createSessionInputBuffer(
+ SessionInputBuffer inBuffer = super.createSessionInputBuffer(
socket,
- buffersize > 0 ? buffersize : 8192,
+ bufferSize > 0 ? bufferSize : 8192,
params);
if (wireLog.isDebugEnabled()) {
- inbuffer = new LoggingSessionInputBuffer(
- inbuffer,
+ inBuffer = new LoggingSessionInputBuffer(
+ inBuffer,
new Wire(wireLog),
HttpProtocolParams.getHttpElementCharset(params));
}
- return inbuffer;
+ return inBuffer;
}
@Override
protected SessionOutputBuffer createSessionOutputBuffer(
final Socket socket,
- final int buffersize,
+ final int bufferSize,
final HttpParams params) throws IOException {
SessionOutputBuffer outbuffer = super.createSessionOutputBuffer(
socket,
- buffersize > 0 ? buffersize : 8192,
+ bufferSize > 0 ? bufferSize : 8192,
params);
if (wireLog.isDebugEnabled()) {
outbuffer = new LoggingSessionOutputBuffer(
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpConnPool.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpConnPool.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpConnPool.java
index c89dbe4..f9bf401 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpConnPool.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpConnPool.java
@@ -49,22 +49,22 @@ class HttpConnPool extends AbstractConnPool<HttpRoute, OperatedClientConnection,
private final Log log;
private final long timeToLive;
- private final TimeUnit tunit;
+ private final TimeUnit timeUnit;
public HttpConnPool(final Log log,
final ClientConnectionOperator connOperator,
final int defaultMaxPerRoute, final int maxTotal,
- final long timeToLive, final TimeUnit tunit) {
+ final long timeToLive, final TimeUnit timeUnit) {
super(new InternalConnFactory(connOperator), defaultMaxPerRoute, maxTotal);
this.log = log;
this.timeToLive = timeToLive;
- this.tunit = tunit;
+ this.timeUnit = timeUnit;
}
@Override
protected HttpPoolEntry createEntry(final HttpRoute route, final OperatedClientConnection conn) {
final String id = Long.toString(COUNTER.getAndIncrement());
- return new HttpPoolEntry(this.log, id, route, conn, this.timeToLive, this.tunit);
+ return new HttpPoolEntry(this.log, id, route, conn, this.timeToLive, this.timeUnit);
}
static class InternalConnFactory implements ConnFactory<HttpRoute, OperatedClientConnection> {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpPoolEntry.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpPoolEntry.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpPoolEntry.java
index b39d952..9a27688 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpPoolEntry.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpPoolEntry.java
@@ -52,8 +52,8 @@ class HttpPoolEntry extends PoolEntry<HttpRoute, OperatedClientConnection> {
final String id,
final HttpRoute route,
final OperatedClientConnection conn,
- final long timeToLive, final TimeUnit tunit) {
- super(id, route, conn, timeToLive, tunit);
+ final long timeToLive, final TimeUnit timeUnit) {
+ super(id, route, conn, timeToLive, timeUnit);
this.log = log;
this.tracker = new RouteTracker(route);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/LoggingSessionInputBuffer.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
index a0b37ae..6013a29 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
@@ -83,29 +83,29 @@ public class LoggingSessionInputBuffer implements SessionInputBuffer, EofSensor
@Override
public int read(final byte[] b, final int off, final int len) throws IOException {
- final int l = this.in.read(b, off, len);
- if (this.wire.enabled() && l > 0) {
- this.wire.input(b, off, l);
+ final int readLen = this.in.read(b, off, len);
+ if (this.wire.enabled() && readLen > 0) {
+ this.wire.input(b, off, readLen);
}
- return l;
+ return readLen;
}
@Override
public int read() throws IOException {
- final int l = this.in.read();
- if (this.wire.enabled() && l != -1) {
- this.wire.input(l);
+ final int b = this.in.read();
+ if (this.wire.enabled() && b != -1) {
+ this.wire.input(b);
}
- return l;
+ return b;
}
@Override
public int read(final byte[] b) throws IOException {
- final int l = this.in.read(b);
- if (this.wire.enabled() && l > 0) {
- this.wire.input(b, 0, l);
+ final int readLen = this.in.read(b);
+ if (this.wire.enabled() && readLen > 0) {
+ this.wire.input(b, 0, readLen);
}
- return l;
+ return readLen;
}
@Override
@@ -120,14 +120,14 @@ public class LoggingSessionInputBuffer implements SessionInputBuffer, EofSensor
@Override
public int readLine(final CharArrayBuffer buffer) throws IOException {
- final int l = this.in.readLine(buffer);
- if (this.wire.enabled() && l >= 0) {
- final int pos = buffer.length() - l;
- final String s = new String(buffer.buffer(), pos, l);
+ final int readLen = this.in.readLine(buffer);
+ if (this.wire.enabled() && readLen >= 0) {
+ final int pos = buffer.length() - readLen;
+ final String s = new String(buffer.buffer(), pos, readLen);
final String tmp = s + "\r\n";
this.wire.input(tmp.getBytes(this.charset));
}
- return l;
+ return readLen;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/PoolingClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/PoolingClientConnectionManager.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/PoolingClientConnectionManager.java
index 3e2fefb..57f3dc6 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/PoolingClientConnectionManager.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/PoolingClientConnectionManager.java
@@ -98,12 +98,12 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
public PoolingClientConnectionManager(
final SchemeRegistry schemeRegistry,
- final long timeToLive, final TimeUnit tunit) {
- this(schemeRegistry, timeToLive, tunit, new SystemDefaultDnsResolver());
+ final long timeToLive, final TimeUnit timeUnit) {
+ this(schemeRegistry, timeToLive, timeUnit, new SystemDefaultDnsResolver());
}
public PoolingClientConnectionManager(final SchemeRegistry schemeRegistry,
- final long timeToLive, final TimeUnit tunit,
+ final long timeToLive, final TimeUnit timeUnit,
final DnsResolver dnsResolver) {
super();
Args.notNull(schemeRegistry, "Scheme registry");
@@ -111,7 +111,7 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
this.schemeRegistry = schemeRegistry;
this.dnsResolver = dnsResolver;
this.operator = createConnectionOperator(schemeRegistry);
- this.pool = new HttpConnPool(this.log, this.operator, 2, 20, timeToLive, tunit);
+ this.pool = new HttpConnPool(this.log, this.operator, 2, 20, timeToLive, timeUnit);
}
@Override
@@ -196,8 +196,8 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
@Override
public ManagedClientConnection getConnection(
final long timeout,
- final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
- return leaseConnection(future, timeout, tunit);
+ final TimeUnit timeUnit) throws InterruptedException, ConnectionPoolTimeoutException {
+ return leaseConnection(future, timeout, timeUnit);
}
};
@@ -207,10 +207,10 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
ManagedClientConnection leaseConnection(
final Future<HttpPoolEntry> future,
final long timeout,
- final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
+ final TimeUnit timeUnit) throws InterruptedException, ConnectionPoolTimeoutException {
final HttpPoolEntry entry;
try {
- entry = future.get(timeout, tunit);
+ entry = future.get(timeout, timeUnit);
if (entry == null || future.isCancelled()) {
throw new InterruptedException();
}
@@ -234,7 +234,7 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
@Override
public void releaseConnection(
- final ManagedClientConnection conn, final long keepalive, final TimeUnit tunit) {
+ final ManagedClientConnection conn, final long keepalive, final TimeUnit timeUnit) {
Args.check(conn instanceof ManagedClientConnectionImpl, "Connection class mismatch, " +
"connection not obtained from this manager");
@@ -257,11 +257,11 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
}
// Only reusable connections can be kept alive
if (managedConn.isMarkedReusable()) {
- entry.updateExpiry(keepalive, tunit != null ? tunit : TimeUnit.MILLISECONDS);
+ entry.updateExpiry(keepalive, timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS);
if (this.log.isDebugEnabled()) {
final String s;
if (keepalive > 0) {
- s = "for " + keepalive + " " + tunit;
+ s = "for " + keepalive + " " + timeUnit;
} else {
s = "indefinitely";
}
@@ -289,11 +289,11 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
}
@Override
- public void closeIdleConnections(final long idleTimeout, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idleTimeout, final TimeUnit timeUnit) {
if (this.log.isDebugEnabled()) {
- this.log.debug("Closing connections idle longer than " + idleTimeout + " " + tunit);
+ this.log.debug("Closing connections idle longer than " + idleTimeout + " " + timeUnit);
}
- this.pool.closeIdle(idleTimeout, tunit);
+ this.pool.closeIdle(idleTimeout, timeUnit);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SingleClientConnManager.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SingleClientConnManager.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SingleClientConnManager.java
index 2861b9b..993fa70 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SingleClientConnManager.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SingleClientConnManager.java
@@ -186,7 +186,7 @@ public class SingleClientConnManager implements ClientConnectionManager {
@Override
public ManagedClientConnection getConnection(
- final long timeout, final TimeUnit tunit) {
+ final long timeout, final TimeUnit timeUnit) {
return SingleClientConnManager.this.getConnection(
route, state);
}
@@ -317,16 +317,16 @@ public class SingleClientConnManager implements ClientConnectionManager {
}
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
assertStillUp();
// idletime can be 0 or negative, no problem there
- Args.notNull(tunit, "Time unit");
+ Args.notNull(timeUnit, "Time unit");
synchronized (this) {
if ((managedConn == null) && uniquePoolEntry.connection.isOpen()) {
final long cutoff =
- System.currentTimeMillis() - tunit.toMillis(idletime);
+ System.currentTimeMillis() - timeUnit.toMillis(idletime);
if (lastReleaseTime <= cutoff) {
try {
uniquePoolEntry.close();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/AbstractConnPool.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
index d9dfbfe..f9fd517 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
@@ -99,7 +99,7 @@ public abstract class AbstractConnPool {
* @param route the route for which to get the connection
* @param state the state
* @param timeout the timeout, 0 or negative for no timeout
- * @param tunit the unit for the {@code timeout},
+ * @param timeUnit the unit for the {@code timeout},
* may be {@code null} only if there is no timeout
*
* @return pool entry holding a connection for the route
@@ -114,9 +114,9 @@ public abstract class AbstractConnPool {
final HttpRoute route,
final Object state,
final long timeout,
- final TimeUnit tunit)
+ final TimeUnit timeUnit)
throws ConnectionPoolTimeoutException, InterruptedException {
- return requestPoolEntry(route, state).getPoolEntry(timeout, tunit);
+ return requestPoolEntry(route, state).getPoolEntry(timeout, timeUnit);
}
/**
@@ -154,16 +154,16 @@ public abstract class AbstractConnPool {
*
* @param idletime the time the connections should have been idle
* in order to be closed now
- * @param tunit the unit for the {@code idletime}
+ * @param timeUnit the unit for the {@code idletime}
*/
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
// idletime can be 0 or negative, no problem there
- Args.notNull(tunit, "Time unit");
+ Args.notNull(timeUnit, "Time unit");
poolLock.lock();
try {
- idleConnHandler.closeIdleConnections(tunit.toMillis(idletime));
+ idleConnHandler.closeIdleConnections(timeUnit.toMillis(idletime));
} finally {
poolLock.unlock();
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
index 31914c4..07f4afd 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
@@ -295,9 +295,9 @@ public class ConnPoolByRoute extends AbstractConnPool {
@Override
public BasicPoolEntry getPoolEntry(
final long timeout,
- final TimeUnit tunit)
+ final TimeUnit timeUnit)
throws InterruptedException, ConnectionPoolTimeoutException {
- return getEntryBlocking(route, state, timeout, tunit, aborter);
+ return getEntryBlocking(route, state, timeout, timeUnit, aborter);
}
};
@@ -310,7 +310,7 @@ public class ConnPoolByRoute extends AbstractConnPool {
*
* @param route the route for which to get the connection
* @param timeout the timeout, 0 or negative for no timeout
- * @param tunit the unit for the {@code timeout},
+ * @param timeUnit the unit for the {@code timeout},
* may be {@code null} only if there is no timeout
* @param aborter an object which can abort a {@link WaitingThread}.
*
@@ -323,14 +323,14 @@ public class ConnPoolByRoute extends AbstractConnPool {
*/
protected BasicPoolEntry getEntryBlocking(
final HttpRoute route, final Object state,
- final long timeout, final TimeUnit tunit,
+ final long timeout, final TimeUnit timeUnit,
final WaitingThreadAborter aborter)
throws ConnectionPoolTimeoutException, InterruptedException {
Date deadline = null;
if (timeout > 0) {
deadline = new Date
- (System.currentTimeMillis() + tunit.toMillis(timeout));
+ (System.currentTimeMillis() + timeUnit.toMillis(timeout));
}
BasicPoolEntry entry = null;
@@ -710,17 +710,17 @@ public class ConnPoolByRoute extends AbstractConnPool {
*
* @param idletime the time the connections should have been idle
* in order to be closed now
- * @param tunit the unit for the {@code idletime}
+ * @param timeUnit the unit for the {@code idletime}
*/
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- Args.notNull(tunit, "Time unit");
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
+ Args.notNull(timeUnit, "Time unit");
final long t = idletime > 0 ? idletime : 0;
if (log.isDebugEnabled()) {
- log.debug("Closing connections idle longer than " + t + " " + tunit);
+ log.debug("Closing connections idle longer than " + t + " " + timeUnit);
}
// the latest time for which connections will be closed
- final long deadline = System.currentTimeMillis() - tunit.toMillis(t);
+ final long deadline = System.currentTimeMillis() - timeUnit.toMillis(t);
poolLock.lock();
try {
final Iterator<BasicPoolEntry> iter = freeConnections.iterator();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java
index 52b3564..5090888 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java
@@ -46,7 +46,7 @@ public interface PoolEntryRequest {
* an {@link InterruptedException} is thrown.
*
* @param timeout the timeout, 0 or negative for no timeout
- * @param tunit the unit for the {@code timeout},
+ * @param timeUnit the unit for the {@code timeout},
* may be {@code null} only if there is no timeout
*
* @return pool entry holding a connection for the route
@@ -58,7 +58,7 @@ public interface PoolEntryRequest {
*/
BasicPoolEntry getPoolEntry(
long timeout,
- TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException;
+ TimeUnit timeUnit) throws InterruptedException, ConnectionPoolTimeoutException;
/**
* Aborts the active or next call to
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
index 74f1118..dd2147a 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
@@ -232,7 +232,7 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager {
@Override
public ManagedClientConnection getConnection(
- final long timeout, final TimeUnit tunit) throws InterruptedException,
+ final long timeout, final TimeUnit timeUnit) throws InterruptedException,
ConnectionPoolTimeoutException {
Args.notNull(route, "Route");
@@ -240,7 +240,7 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager {
log.debug("Get connection: " + route + ", timeout = " + timeout);
}
- final BasicPoolEntry entry = poolRequest.getPoolEntry(timeout, tunit);
+ final BasicPoolEntry entry = poolRequest.getPoolEntry(timeout, timeUnit);
return new BasicPooledConnAdapter(ThreadSafeClientConnManager.this, entry);
}
@@ -327,11 +327,11 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager {
}
@Override
- public void closeIdleConnections(final long idleTimeout, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idleTimeout, final TimeUnit timeUnit) {
if (log.isDebugEnabled()) {
- log.debug("Closing connections idle longer than " + idleTimeout + " " + tunit);
+ log.debug("Closing connections idle longer than " + idleTimeout + " " + timeUnit);
}
- pool.closeIdleConnections(idleTimeout, tunit);
+ pool.closeIdleConnections(idleTimeout, timeUnit);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java b/httpclient/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java
index 30a578e..8e7f0e9 100644
--- a/httpclient/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java
+++ b/httpclient/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java
@@ -112,9 +112,8 @@ public final class AuthSchemeRegistry implements Lookup<AuthSchemeProvider> {
final AuthSchemeFactory factory = registeredSchemes.get(name.toLowerCase(Locale.ENGLISH));
if (factory != null) {
return factory.newInstance(params);
- } else {
- throw new IllegalStateException("Unsupported authentication scheme: " + name);
}
+ throw new IllegalStateException("Unsupported authentication scheme: " + name);
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java b/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java
index 08d7c6d..27ee00d 100644
--- a/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java
+++ b/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java
@@ -79,23 +79,22 @@ public class DecompressingEntity extends HttpEntityWrapper {
content = getDecompressingStream();
}
return content;
- } else {
- return getDecompressingStream();
}
+ return getDecompressingStream();
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = getContent();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final InputStream inStream = getContent();
try {
final byte[] buffer = new byte[BUFFER_SIZE];
int l;
- while ((l = instream.read(buffer)) != -1) {
- outstream.write(buffer, 0, l);
+ while ((l = inStream.read(buffer)) != -1) {
+ outStream.write(buffer, 0, l);
}
} finally {
- instream.close();
+ inStream.close();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/client/entity/GzipCompressingEntity.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/client/entity/GzipCompressingEntity.java b/httpclient/src/main/java/org/apache/http/client/entity/GzipCompressingEntity.java
index 3008239..cfa45df 100644
--- a/httpclient/src/main/java/org/apache/http/client/entity/GzipCompressingEntity.java
+++ b/httpclient/src/main/java/org/apache/http/client/entity/GzipCompressingEntity.java
@@ -101,9 +101,9 @@ public class GzipCompressingEntity extends HttpEntityWrapper {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final GZIPOutputStream gzip = new GZIPOutputStream(outstream);
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final GZIPOutputStream gzip = new GZIPOutputStream(outStream);
wrappedEntity.writeTo(gzip);
// Only close output stream if the wrapped entity has been
// successfully written out
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/client/entity/InputStreamFactory.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/client/entity/InputStreamFactory.java b/httpclient/src/main/java/org/apache/http/client/entity/InputStreamFactory.java
index 4753cf6..56d99d6 100644
--- a/httpclient/src/main/java/org/apache/http/client/entity/InputStreamFactory.java
+++ b/httpclient/src/main/java/org/apache/http/client/entity/InputStreamFactory.java
@@ -36,6 +36,6 @@ import java.io.InputStream;
*/
public interface InputStreamFactory {
- InputStream create(InputStream instream) throws IOException;
+ InputStream create(InputStream inStream) throws IOException;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java
index dbfbd0e..c52ece5 100644
--- a/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java
+++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java
@@ -189,11 +189,10 @@ public class HttpRequestWrapper extends AbstractHttpMessage implements HttpUriRe
*/
public static HttpRequestWrapper wrap(final HttpRequest request, final HttpHost target) {
Args.notNull(request, "HTTP request");
- if (request instanceof HttpEntityEnclosingRequest) {
- return new HttpEntityEnclosingRequestWrapper((HttpEntityEnclosingRequest) request, target);
- } else {
- return new HttpRequestWrapper(request, target);
- }
+ return request instanceof HttpEntityEnclosingRequest
+ ? new HttpEntityEnclosingRequestWrapper(
+ (HttpEntityEnclosingRequest) request, target)
+ : new HttpRequestWrapper(request, target);
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/client/protocol/HttpClientContext.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/HttpClientContext.java b/httpclient/src/main/java/org/apache/http/client/protocol/HttpClientContext.java
index e763e9a..e815d8a 100644
--- a/httpclient/src/main/java/org/apache/http/client/protocol/HttpClientContext.java
+++ b/httpclient/src/main/java/org/apache/http/client/protocol/HttpClientContext.java
@@ -134,11 +134,9 @@ public class HttpClientContext extends HttpCoreContext {
public static final String REQUEST_CONFIG = "http.request-config";
public static HttpClientContext adapt(final HttpContext context) {
- if (context instanceof HttpClientContext) {
- return (HttpClientContext) context;
- } else {
- return new HttpClientContext(context);
- }
+ return context instanceof HttpClientContext
+ ? (HttpClientContext) context
+ : new HttpClientContext(context);
}
public static HttpClientContext create() {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java
index be8e56d..ed2db74 100644
--- a/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java
+++ b/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java
@@ -59,15 +59,13 @@ public class CloneUtils {
final Throwable cause = ex.getCause();
if (cause instanceof CloneNotSupportedException) {
throw ((CloneNotSupportedException) cause);
- } else {
- throw new Error("Unexpected exception", cause);
}
+ throw new Error("Unexpected exception", cause);
} catch (final IllegalAccessException ex) {
throw new IllegalAccessError(ex.getMessage());
}
- } else {
- throw new CloneNotSupportedException();
}
+ throw new CloneNotSupportedException();
}
public static Object clone(final Object obj) throws CloneNotSupportedException {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java b/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java
index 0a79b4a..35c74de 100644
--- a/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java
+++ b/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java
@@ -495,11 +495,9 @@ public class URIBuilder {
}
public List<NameValuePair> getQueryParams() {
- if (this.queryParams != null) {
- return new ArrayList<NameValuePair>(this.queryParams);
- } else {
- return new ArrayList<NameValuePair>();
- }
+ return this.queryParams != null
+ ? new ArrayList<NameValuePair>(this.queryParams)
+ : new ArrayList<NameValuePair>();
}
public String getFragment() {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
index 02f8c1a..7bb01c6 100644
--- a/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
+++ b/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
@@ -211,20 +211,12 @@ public class URIUtils {
}
if (route.getProxyHost() != null && !route.isTunnelled()) {
// Make sure the request URI is absolute
- if (!uri.isAbsolute()) {
- final HttpHost target = route.getTargetHost();
- return rewriteURI(uri, target, true);
- } else {
- return rewriteURI(uri);
- }
- } else {
- // Make sure the request URI is relative
- if (uri.isAbsolute()) {
- return rewriteURI(uri, null, true);
- } else {
- return rewriteURI(uri);
- }
+ return uri.isAbsolute()
+ ? rewriteURI(uri)
+ : rewriteURI(uri, route.getTargetHost(), true);
}
+ // Make sure the request URI is relative
+ return uri.isAbsolute() ? rewriteURI(uri, null, true) : rewriteURI(uri);
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java
index d85cf8d..0397cc4 100644
--- a/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java
+++ b/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java
@@ -124,14 +124,14 @@ public class URLEncodedUtils {
final long len = entity.getContentLength();
Args.check(len <= Integer.MAX_VALUE, "HTTP entity is too large");
final Charset charset = contentType.getCharset() != null ? contentType.getCharset() : HTTP.DEF_CONTENT_CHARSET;
- final InputStream instream = entity.getContent();
- if (instream == null) {
+ final InputStream inStream = entity.getContent();
+ if (inStream == null) {
return createEmptyList();
}
final CharArrayBuffer buf;
try {
buf = new CharArrayBuffer(len > 0 ? (int) len : 1024);
- final Reader reader = new InputStreamReader(instream, charset);
+ final Reader reader = new InputStreamReader(inStream, charset);
final char[] tmp = new char[1024];
int l;
while((l = reader.read(tmp)) != -1) {
@@ -139,7 +139,7 @@ public class URLEncodedUtils {
}
} finally {
- instream.close();
+ inStream.close();
}
if (buf.isEmpty()) {
return createEmptyList();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java b/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java
index 8b30e68..845507c 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java
@@ -92,11 +92,11 @@ public interface ClientConnectionManager {
* All expired connections will also be closed.
*
* @param idletime the idle time of connections to be closed
- * @param tunit the unit for the {@code idletime}
+ * @param timeUnit the unit for the {@code idletime}
*
* @see #closeExpiredConnections()
*/
- void closeIdleConnections(long idletime, TimeUnit tunit);
+ void closeIdleConnections(long idletime, TimeUnit timeUnit);
/**
* Closes all expired connections in the pool.
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java b/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java
index cd8d5c4..afb053e 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java
@@ -51,7 +51,7 @@ public interface ClientConnectionRequest {
* be thrown.
*
* @param timeout the timeout, 0 or negative for no timeout
- * @param tunit the unit for the {@code timeout},
+ * @param timeUnit the unit for the {@code timeout},
* may be {@code null} only if there is no timeout
*
* @return a connection that can be used to communicate
@@ -62,7 +62,7 @@ public interface ClientConnectionRequest {
* @throws InterruptedException
* if the calling thread is interrupted while waiting
*/
- ManagedClientConnection getConnection(long timeout, TimeUnit tunit)
+ ManagedClientConnection getConnection(long timeout, TimeUnit timeUnit)
throws InterruptedException, ConnectionPoolTimeoutException;
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/conn/ConnectionRequest.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/ConnectionRequest.java b/httpclient/src/main/java/org/apache/http/conn/ConnectionRequest.java
index 3520a52..ccd9eb3 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ConnectionRequest.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ConnectionRequest.java
@@ -52,7 +52,7 @@ public interface ConnectionRequest extends Cancellable {
* be thrown.
*
* @param timeout the timeout, 0 or negative for no timeout
- * @param tunit the unit for the {@code timeout},
+ * @param timeUnit the unit for the {@code timeout},
* may be {@code null} only if there is no timeout
*
* @return a connection that can be used to communicate
@@ -63,7 +63,7 @@ public interface ConnectionRequest extends Cancellable {
* @throws InterruptedException
* if the calling thread is interrupted while waiting
*/
- HttpClientConnection get(long timeout, TimeUnit tunit)
+ HttpClientConnection get(long timeout, TimeUnit timeUnit)
throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/conn/EofSensorInputStream.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/EofSensorInputStream.java b/httpclient/src/main/java/org/apache/http/conn/EofSensorInputStream.java
index fb7de2d..774c65b 100644
--- a/httpclient/src/main/java/org/apache/http/conn/EofSensorInputStream.java
+++ b/httpclient/src/main/java/org/apache/http/conn/EofSensorInputStream.java
@@ -111,36 +111,36 @@ public class EofSensorInputStream extends InputStream implements ConnectionRelea
@Override
public int read() throws IOException {
- int l = -1;
+ int readLen = -1;
if (isReadAllowed()) {
try {
- l = wrappedStream.read();
- checkEOF(l);
+ readLen = wrappedStream.read();
+ checkEOF(readLen);
} catch (final IOException ex) {
checkAbort();
throw ex;
}
}
- return l;
+ return readLen;
}
@Override
public int read(final byte[] b, final int off, final int len) throws IOException {
- int l = -1;
+ int readLen = -1;
if (isReadAllowed()) {
try {
- l = wrappedStream.read(b, off, len);
- checkEOF(l);
+ readLen = wrappedStream.read(b, off, len);
+ checkEOF(readLen);
} catch (final IOException ex) {
checkAbort();
throw ex;
}
}
- return l;
+ return readLen;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java b/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java
index 70c2908..d39f179 100644
--- a/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java
+++ b/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java
@@ -155,11 +155,11 @@ public interface HttpClientConnectionManager {
* </p>
*
* @param idletime the idle time of connections to be closed
- * @param tunit the unit for the {@code idletime}
+ * @param timeUnit the unit for the {@code idletime}
*
* @see #closeExpiredConnections()
*/
- void closeIdleConnections(long idletime, TimeUnit tunit);
+ void closeIdleConnections(long idletime, TimeUnit timeUnit);
/**
* Closes all expired connections in the pool.
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java b/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java
index 8a06797..2d5384e 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java
@@ -32,7 +32,6 @@ import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLSession;
-import org.apache.http.HttpClientConnection;
import org.apache.http.HttpHost;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.params.HttpParams;
@@ -48,7 +47,7 @@ import org.apache.http.protocol.HttpContext;
*/
@Deprecated
public interface ManagedClientConnection extends
- HttpClientConnection, HttpRoutedConnection, ManagedHttpClientConnection, ConnectionReleaseTrigger {
+ HttpRoutedConnection, ManagedHttpClientConnection, ConnectionReleaseTrigger {
/**
* Indicates whether this connection is secure.
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java b/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java
index 60a02e7..bf843da 100644
--- a/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java
+++ b/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java
@@ -103,16 +103,13 @@ public final class HttpRoute implements RouteInfo, Cloneable {
private static HttpHost normalize(final HttpHost target) {
if (target.getPort() >= 0 ) {
return target;
- } else {
- final InetAddress address = target.getAddress();
- final String schemeName = target.getSchemeName();
- if (address != null) {
- return new HttpHost(address, getDefaultPort(schemeName), schemeName);
- } else {
- final String hostName = target.getHostName();
- return new HttpHost(hostName, getDefaultPort(schemeName), schemeName);
- }
}
+ final InetAddress address = target.getAddress();
+ final String schemeName = target.getSchemeName();
+ return address != null
+ ? new HttpHost(address, getDefaultPort(schemeName), schemeName)
+ : new HttpHost(target.getHostName(), getDefaultPort(schemeName),
+ schemeName);
}
/**
@@ -238,11 +235,7 @@ public final class HttpRoute implements RouteInfo, Cloneable {
Args.notNegative(hop, "Hop index");
final int hopcount = getHopCount();
Args.check(hop < hopcount, "Hop index exceeds tracked route length");
- if (hop < hopcount - 1) {
- return this.proxyChain.get(hop);
- } else {
- return this.targetHost;
- }
+ return hop < hopcount - 1 ? this.proxyChain.get(hop) : this.targetHost;
}
@Override
@@ -298,9 +291,8 @@ public final class HttpRoute implements RouteInfo, Cloneable {
LangUtils.equals(this.targetHost, that.targetHost) &&
LangUtils.equals(this.localAddress, that.localAddress) &&
LangUtils.equals(this.proxyChain, that.proxyChain);
- } else {
- return false;
}
+ return false;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java b/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java
index 6d02b95..3201710 100644
--- a/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java
+++ b/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java
@@ -163,14 +163,11 @@ public final class Scheme {
public final SocketFactory getSocketFactory() {
if (this.socketFactory instanceof SchemeSocketFactoryAdaptor) {
return ((SchemeSocketFactoryAdaptor) this.socketFactory).getFactory();
- } else {
- if (this.layered) {
- return new LayeredSocketFactoryAdaptor(
- (LayeredSchemeSocketFactory) this.socketFactory);
- } else {
- return new SocketFactoryAdaptor(this.socketFactory);
- }
}
+ return this.layered
+ ? new LayeredSocketFactoryAdaptor(
+ (LayeredSchemeSocketFactory) this.socketFactory)
+ : new SocketFactoryAdaptor(this.socketFactory);
}
/**
@@ -245,9 +242,8 @@ public final class Scheme {
return this.name.equals(that.name)
&& this.defaultPort == that.defaultPort
&& this.layered == that.layered;
- } else {
- return false;
}
+ return false;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java b/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java
index 08de43e..049145d 100644
--- a/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java
+++ b/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java
@@ -88,11 +88,9 @@ class SchemeSocketFactoryAdaptor implements SchemeSocketFactory {
if (this == obj) {
return true;
}
- if (obj instanceof SchemeSocketFactoryAdaptor) {
- return this.factory.equals(((SchemeSocketFactoryAdaptor)obj).factory);
- } else {
- return this.factory.equals(obj);
- }
+ return obj instanceof SchemeSocketFactoryAdaptor
+ ? this.factory.equals(((SchemeSocketFactoryAdaptor) obj).factory)
+ : this.factory.equals(obj);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/conn/scheme/SocketFactoryAdaptor.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/scheme/SocketFactoryAdaptor.java b/httpclient/src/main/java/org/apache/http/conn/scheme/SocketFactoryAdaptor.java
index 3a9f9a0..65a160b 100644
--- a/httpclient/src/main/java/org/apache/http/conn/scheme/SocketFactoryAdaptor.java
+++ b/httpclient/src/main/java/org/apache/http/conn/scheme/SocketFactoryAdaptor.java
@@ -85,11 +85,9 @@ class SocketFactoryAdaptor implements SocketFactory {
if (this == obj) {
return true;
}
- if (obj instanceof SocketFactoryAdaptor) {
- return this.factory.equals(((SocketFactoryAdaptor)obj).factory);
- } else {
- return this.factory.equals(obj);
- }
+ return obj instanceof SocketFactoryAdaptor
+ ? this.factory.equals(((SocketFactoryAdaptor) obj).factory)
+ : this.factory.equals(obj);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java b/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java
index ec7c0bf..4877b30 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java
@@ -214,9 +214,8 @@ public abstract class AbstractVerifier implements X509HostnameVerifier {
match = normalizedHost.endsWith(normalizedIdentity.substring(1));
}
return match && (!strict || countDots(normalizedHost) == countDots(normalizedIdentity));
- } else {
- return normalizedHost.equals(normalizedIdentity);
}
+ return normalizedHost.equals(normalizedIdentity);
}
private static boolean validCountryWildcard(final String parts[]) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
index e7f9b28..6ec4412 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
@@ -351,9 +351,8 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
sslsock.startHandshake();
verifyHostname(sslsock, host.getHostName());
return sock;
- } else {
- return createLayeredSocket(sock, host.getHostName(), remoteAddress.getPort(), context);
}
+ return createLayeredSocket(sock, host.getHostName(), remoteAddress.getPort(), context);
}
@Override