You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2018/08/04 16:40:10 UTC
[1/2] httpcomponents-client git commit: Static methods should be
accessed directly. Remove redundant type arguments. Remove exceptions not
thrown from method signatures. Add missing @Override. Remove unnecessary
semicolons. Don't nest unnecessarily.
Repository: httpcomponents-client
Updated Branches:
refs/heads/master 50802106f -> 8d87cf515
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpClientCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpClientCompatibilityTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpClientCompatibilityTest.java
index 736f4d6..42cfc60 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpClientCompatibilityTest.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpClientCompatibilityTest.java
@@ -116,7 +116,7 @@ public class HttpClientCompatibilityTest {
client.close();
}
- enum TestResult {OK, NOK};
+ enum TestResult {OK, NOK}
private void logResult(final TestResult result, final HttpRequest request, final String message) {
final StringBuilder buf = new StringBuilder();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java
index f2366eb..398cea2 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java
@@ -464,9 +464,8 @@ public class TestClientAuthentication extends LocalServerTestBase {
public boolean authenticate(final URIAuthority authority, final String requestUri, final String credentials) {
if (requestUri.equals("/secure") || requestUri.startsWith("/secure/")) {
return super.authenticate(authority, requestUri, credentials);
- } else {
- return true;
}
+ return true;
}
});
@@ -667,14 +666,9 @@ public class TestClientAuthentication extends LocalServerTestBase {
public boolean authenticate(final URIAuthority authority, final String requestUri, final String credentials) {
final boolean authenticated = super.authenticate(authority, requestUri, credentials);
if (authenticated) {
- if (this.count.incrementAndGet() % 4 != 0) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
+ return this.count.incrementAndGet() % 4 != 0;
}
+ return false;
}
};
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java b/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java
index 8558386..98c0784 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java
@@ -271,9 +271,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/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleBody.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleBody.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleBody.java
index b96aa99..0583f16 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleBody.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleBody.java
@@ -49,11 +49,10 @@ public final class SimpleBody {
Args.notNull(body, "Body");
if (body.length() > 2048) {
return new SimpleBody(null, body, contentType);
- } else {
- final Charset charset = (contentType != null ? contentType : ContentType.DEFAULT_TEXT).getCharset();
- final byte[] bytes = body.getBytes(charset != null ? charset : StandardCharsets.US_ASCII);
- return new SimpleBody(bytes, null, contentType);
}
+ final Charset charset = (contentType != null ? contentType : ContentType.DEFAULT_TEXT).getCharset();
+ final byte[] bytes = body.getBytes(charset != null ? charset : StandardCharsets.US_ASCII);
+ return new SimpleBody(bytes, null, contentType);
}
static SimpleBody create(final byte[] body, final ContentType contentType) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthScope.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthScope.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthScope.java
index dfcc594..2bc4a29 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthScope.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthScope.java
@@ -216,9 +216,8 @@ public class AuthScope {
&& this.port == that.port
&& LangUtils.equals(this.realm, that.realm)
&& LangUtils.equals(this.authScheme, that.authScheme);
- } else {
- return false;
}
+ return false;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/entity/DecompressingEntity.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/DecompressingEntity.java b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/DecompressingEntity.java
index fbc8bcc..9cb8427 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/DecompressingEntity.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/DecompressingEntity.java
@@ -78,9 +78,8 @@ public class DecompressingEntity extends HttpEntityWrapper {
content = getDecompressingStream();
}
return content;
- } else {
- return getDecompressingStream();
}
+ return getDecompressingStream();
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/FormBodyPartBuilder.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/FormBodyPartBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/FormBodyPartBuilder.java
index d2610e2..234c991 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/FormBodyPartBuilder.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/FormBodyPartBuilder.java
@@ -111,7 +111,7 @@ public class FormBodyPartBuilder {
headerCopy.addField(field);
}
if (headerCopy.getField(MIME.CONTENT_DISPOSITION) == null) {
- final List<NameValuePair> fieldParameters = new ArrayList<NameValuePair>();
+ final List<NameValuePair> fieldParameters = new ArrayList<>();
fieldParameters.add(new BasicNameValuePair(MIME.FIELD_PARAM_NAME, this.name));
if (this.body.getFilename() != null) {
fieldParameters.add(new BasicNameValuePair(MIME.FIELD_PARAM_FILENAME, this.body.getFilename()));
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/MinimalField.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/MinimalField.java b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/MinimalField.java
index 437330f..c1eef24 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/MinimalField.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/MinimalField.java
@@ -58,7 +58,7 @@ public class MinimalField {
this.name = name;
this.value = value;
this.parameters = parameters != null ?
- Collections.unmodifiableList(new ArrayList<NameValuePair>(parameters)) : Collections.<NameValuePair>emptyList();
+ Collections.unmodifiableList(new ArrayList<>(parameters)) : Collections.<NameValuePair>emptyList();
}
public MinimalField(final MinimalField from) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/AuthSupport.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/AuthSupport.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/AuthSupport.java
index eb8c7e8..31cfc38 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/AuthSupport.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/AuthSupport.java
@@ -80,9 +80,8 @@ public class AuthSupport {
target.getHostName(),
route.getTargetHost().getPort(),
target.getSchemeName());
- } else {
- return target;
}
+ return target;
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/Operations.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/Operations.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/Operations.java
index 076e4e1..94e5df9 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/Operations.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/Operations.java
@@ -77,7 +77,7 @@ public final class Operations {
return true;
}
- };
+ }
public static Cancellable nonCancellable() {
return NOOP_CANCELLABLE;
@@ -86,20 +86,18 @@ public final class Operations {
public static Cancellable cancellable(final Future<?> future) {
if (future == null) {
return NOOP_CANCELLABLE;
- } else {
- if (future instanceof Cancellable) {
- return (Cancellable) future;
- } else {
- return new Cancellable() {
-
- @Override
- public boolean cancel() {
- return future.cancel(true);
- }
-
- };
- }
}
+ if (future instanceof Cancellable) {
+ return (Cancellable) future;
+ }
+ return new Cancellable() {
+
+ @Override
+ public boolean cancel() {
+ return future.cancel(true);
+ }
+
+ };
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java
index 06ce3d6..e82f273 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java
@@ -339,15 +339,13 @@ public final class AsyncConnectExec implements AsyncExecChainHandler {
if (needAuthentication(proxyAuthExchange, proxy, response, clientContext)) {
state.challenged = true;
return null;
- } else {
- state.challenged = false;
- if (status >= HttpStatus.SC_REDIRECTION) {
- state.tunnelRefused = true;
- return asyncExecCallback.handleResponse(response, entityDetails);
- } else {
- return null;
- }
}
+ state.challenged = false;
+ if (status >= HttpStatus.SC_REDIRECTION) {
+ state.tunnelRefused = true;
+ return asyncExecCallback.handleResponse(response, entityDetails);
+ }
+ return null;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncProtocolExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncProtocolExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncProtocolExec.java
index 791a671..be88033 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncProtocolExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncProtocolExec.java
@@ -183,10 +183,9 @@ class AsyncProtocolExec implements AsyncExecChainHandler {
if (needAuthentication(targetAuthExchange, proxyAuthExchange, route, request, response, clientContext)) {
challenged.set(true);
return null;
- } else {
- challenged.set(false);
- return asyncExecCallback.handleResponse(response, entityDetails);
}
+ challenged.set(false);
+ return asyncExecCallback.handleResponse(response, entityDetails);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncPushConsumerRegistry.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncPushConsumerRegistry.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncPushConsumerRegistry.java
index f5b8035..cdc87a9 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncPushConsumerRegistry.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncPushConsumerRegistry.java
@@ -32,7 +32,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.apache.hc.core5.function.Supplier;
-import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
import org.apache.hc.core5.http.protocol.UriPatternMatcher;
@@ -60,7 +59,7 @@ class AsyncPushConsumerRegistry {
return primary;
}
- public AsyncPushConsumer get(final HttpRequest request) throws HttpException {
+ public AsyncPushConsumer get(final HttpRequest request) {
Args.notNull(request, "Request");
final URIAuthority authority = request.getAuthority();
final String key = authority != null ? authority.getHostName().toLowerCase(Locale.ROOT) : null;
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java
index e930fab..1904efc 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java
@@ -167,9 +167,8 @@ class AsyncRedirectExec implements AsyncExecChainHandler {
log.debug(scope.exchangeId + ": redirecting to '" + state.redirectURI + "' via " + currentRoute);
}
return null;
- } else {
- return asyncExecCallback.handleResponse(response, entityDetails);
}
+ return asyncExecCallback.handleResponse(response, entityDetails);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientEventHandlerFactory.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientEventHandlerFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientEventHandlerFactory.java
index 3bbc9c8..2349de5 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientEventHandlerFactory.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientEventHandlerFactory.java
@@ -180,15 +180,14 @@ class Http2AsyncClientEventHandlerFactory implements IOEventHandlerFactory {
});
final LoggingIOSession loggingIOSession = new LoggingIOSession(ioSession, id, sessionLog, wireLog);
return new Http2OnlyClientProtocolNegotiator(loggingIOSession, http2StreamHandlerFactory, false);
- } else {
- final ClientHttp2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientHttp2StreamMultiplexerFactory(
- httpProcessor,
- exchangeHandlerFactory,
- h2Config,
- charCodingConfig,
- null);
- return new Http2OnlyClientProtocolNegotiator(ioSession, http2StreamHandlerFactory, false);
}
+ final ClientHttp2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientHttp2StreamMultiplexerFactory(
+ httpProcessor,
+ exchangeHandlerFactory,
+ h2Config,
+ charCodingConfig,
+ null);
+ return new Http2OnlyClientProtocolNegotiator(ioSession, http2StreamHandlerFactory, false);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientEventHandlerFactory.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientEventHandlerFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientEventHandlerFactory.java
index 71f3a80..f0d2784 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientEventHandlerFactory.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientEventHandlerFactory.java
@@ -255,27 +255,26 @@ class HttpAsyncClientEventHandlerFactory implements IOEventHandlerFactory {
http1StreamHandlerFactory,
http2StreamHandlerFactory,
attachment instanceof HttpVersionPolicy ? (HttpVersionPolicy) attachment : versionPolicy);
- } else {
- final ClientHttp1StreamDuplexerFactory http1StreamHandlerFactory = new ClientHttp1StreamDuplexerFactory(
- httpProcessor,
- h1Config,
- charCodingConfig,
- http1ConnectionReuseStrategy,
- http1ResponseParserFactory,
- http1RequestWriterFactory,
- null);
- final ClientHttp2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientHttp2StreamMultiplexerFactory(
- httpProcessor,
- exchangeHandlerFactory,
- h2Config,
- charCodingConfig,
- null);
- return new ClientHttpProtocolNegotiator(
- ioSession,
- http1StreamHandlerFactory,
- http2StreamHandlerFactory,
- attachment instanceof HttpVersionPolicy ? (HttpVersionPolicy) attachment : versionPolicy);
}
+ final ClientHttp1StreamDuplexerFactory http1StreamHandlerFactory = new ClientHttp1StreamDuplexerFactory(
+ httpProcessor,
+ h1Config,
+ charCodingConfig,
+ http1ConnectionReuseStrategy,
+ http1ResponseParserFactory,
+ http1RequestWriterFactory,
+ null);
+ final ClientHttp2StreamMultiplexerFactory http2StreamHandlerFactory = new ClientHttp2StreamMultiplexerFactory(
+ httpProcessor,
+ exchangeHandlerFactory,
+ h2Config,
+ charCodingConfig,
+ null);
+ return new ClientHttpProtocolNegotiator(
+ ioSession,
+ http1StreamHandlerFactory,
+ http2StreamHandlerFactory,
+ attachment instanceof HttpVersionPolicy ? (HttpVersionPolicy) attachment : versionPolicy);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttp2AsyncExecRuntime.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttp2AsyncExecRuntime.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttp2AsyncExecRuntime.java
index 5708b39..c589169 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttp2AsyncExecRuntime.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttp2AsyncExecRuntime.java
@@ -99,10 +99,9 @@ class InternalHttp2AsyncExecRuntime implements AsyncExecRuntime {
}
}));
- } else {
- callback.completed(this);
- return Operations.nonCancellable();
}
+ callback.completed(this);
+ return Operations.nonCancellable();
}
@Override
@@ -126,11 +125,10 @@ class InternalHttp2AsyncExecRuntime implements AsyncExecRuntime {
if (reusable) {
final Endpoint endpoint = sessionRef.get();
return endpoint != null && !endpoint.session.isClosed();
- } else {
- final Endpoint endpoint = sessionRef.getAndSet(null);
- if (endpoint != null) {
- endpoint.session.shutdown(ShutdownType.GRACEFUL);
- }
+ }
+ final Endpoint endpoint = sessionRef.getAndSet(null);
+ if (endpoint != null) {
+ endpoint.session.shutdown(ShutdownType.GRACEFUL);
}
return false;
}
@@ -158,30 +156,29 @@ class InternalHttp2AsyncExecRuntime implements AsyncExecRuntime {
if (!endpoint.session.isClosed()) {
callback.completed(this);
return Operations.nonCancellable();
- } else {
- final HttpHost target = endpoint.target;
- final RequestConfig requestConfig = context.getRequestConfig();
- return Operations.cancellable(connPool.getSession(target, requestConfig.getConnectionTimeout(), new FutureCallback<IOSession>() {
-
- @Override
- public void completed(final IOSession ioSession) {
- sessionRef.set(new Endpoint(target, ioSession));
- reusable = true;
- callback.completed(InternalHttp2AsyncExecRuntime.this);
- }
+ }
+ final HttpHost target = endpoint.target;
+ final RequestConfig requestConfig = context.getRequestConfig();
+ return Operations.cancellable(connPool.getSession(target, requestConfig.getConnectionTimeout(), new FutureCallback<IOSession>() {
+
+ @Override
+ public void completed(final IOSession ioSession) {
+ sessionRef.set(new Endpoint(target, ioSession));
+ reusable = true;
+ callback.completed(InternalHttp2AsyncExecRuntime.this);
+ }
- @Override
- public void failed(final Exception ex) {
- callback.failed(ex);
- }
+ @Override
+ public void failed(final Exception ex) {
+ callback.failed(ex);
+ }
- @Override
- public void cancelled() {
- callback.cancelled();
- }
+ @Override
+ public void cancelled() {
+ callback.cancelled();
+ }
- }));
- }
+ }));
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncExecRuntime.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncExecRuntime.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncExecRuntime.java
index e48b8dd..8c0fb09 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncExecRuntime.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncExecRuntime.java
@@ -109,10 +109,9 @@ class InternalHttpAsyncExecRuntime implements AsyncExecRuntime {
callback.cancelled();
}
}));
- } else {
- callback.completed(this);
- return Operations.nonCancellable();
}
+ callback.completed(this);
+ return Operations.nonCancellable();
}
private void discardEndpoint(final AsyncConnectionEndpoint endpoint) {
@@ -158,11 +157,10 @@ class InternalHttpAsyncExecRuntime implements AsyncExecRuntime {
if (reusable) {
final AsyncConnectionEndpoint endpoint = endpointRef.get();
return endpoint != null && endpoint.isConnected();
- } else {
- final AsyncConnectionEndpoint endpoint = endpointRef.getAndSet(null);
- if (endpoint != null) {
- discardEndpoint(endpoint);
- }
+ }
+ final AsyncConnectionEndpoint endpoint = endpointRef.getAndSet(null);
+ if (endpoint != null) {
+ discardEndpoint(endpoint);
}
return false;
}
@@ -189,37 +187,36 @@ class InternalHttpAsyncExecRuntime implements AsyncExecRuntime {
if (endpoint.isConnected()) {
callback.completed(this);
return Operations.nonCancellable();
- } else {
- final RequestConfig requestConfig = context.getRequestConfig();
- final TimeValue timeout = requestConfig.getConnectionTimeout();
- return Operations.cancellable(manager.connect(
- endpoint,
- connectionInitiator,
- timeout,
- versionPolicy,
- context,
- new FutureCallback<AsyncConnectionEndpoint>() {
-
- @Override
- public void completed(final AsyncConnectionEndpoint endpoint) {
- if (TimeValue.isPositive(timeout)) {
- endpoint.setSocketTimeout(timeout.toMillisIntBound());
- }
- callback.completed(InternalHttpAsyncExecRuntime.this);
+ }
+ final RequestConfig requestConfig = context.getRequestConfig();
+ final TimeValue timeout = requestConfig.getConnectionTimeout();
+ return Operations.cancellable(manager.connect(
+ endpoint,
+ connectionInitiator,
+ timeout,
+ versionPolicy,
+ context,
+ new FutureCallback<AsyncConnectionEndpoint>() {
+
+ @Override
+ public void completed(final AsyncConnectionEndpoint endpoint) {
+ if (TimeValue.isPositive(timeout)) {
+ endpoint.setSocketTimeout(timeout.toMillisIntBound());
}
+ callback.completed(InternalHttpAsyncExecRuntime.this);
+ }
- @Override
- public void failed(final Exception ex) {
- callback.failed(ex);
- }
+ @Override
+ public void failed(final Exception ex) {
+ callback.failed(ex);
+ }
- @Override
- public void cancelled() {
- callback.cancelled();
- }
+ @Override
+ public void cancelled() {
+ callback.cancelled();
+ }
- }));
- }
+ }));
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/CredSspScheme.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/CredSspScheme.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/CredSspScheme.java
index 62484ae..1cb0299 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/CredSspScheme.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/CredSspScheme.java
@@ -1033,10 +1033,7 @@ public class CredSspScheme implements AuthScheme
}
return length;
}
- else
- {
- return bufByte;
- }
+ return bufByte;
}
static void getLengthAndAssert( final ByteBuffer buf, final int expectedValue, final String errorMessage )
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/NTLMEngineImpl.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/NTLMEngineImpl.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/NTLMEngineImpl.java
index e3a4dc3..e89fe6a 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/NTLMEngineImpl.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/NTLMEngineImpl.java
@@ -268,7 +268,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;
}
@@ -276,14 +276,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) {
@@ -295,7 +295,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);
@@ -304,7 +304,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);
@@ -379,8 +379,7 @@ final class NTLMEngineImpl implements NTLMEngine {
}
/** Calculate and return client challenge */
- public byte[] getClientChallenge()
- throws NTLMEngineException {
+ public byte[] getClientChallenge() {
if (clientChallenge == null) {
clientChallenge = makeRandomChallenge(random);
}
@@ -388,8 +387,7 @@ final class NTLMEngineImpl implements NTLMEngine {
}
/** Calculate and return second client challenge */
- public byte[] getClientChallenge2()
- throws NTLMEngineException {
+ public byte[] getClientChallenge2() {
if (clientChallenge2 == null) {
clientChallenge2 = makeRandomChallenge(random);
}
@@ -397,8 +395,7 @@ final class NTLMEngineImpl implements NTLMEngine {
}
/** Calculate and return random secondary key */
- public byte[] getSecondaryKey()
- throws NTLMEngineException {
+ public byte[] getSecondaryKey() {
if (secondaryKey == null) {
secondaryKey = makeSecondaryKey(random);
}
@@ -476,8 +473,7 @@ final class NTLMEngineImpl implements NTLMEngine {
}
/** Calculate the NTLMv2Blob */
- public byte[] getNTLMv2Blob()
- throws NTLMEngineException {
+ public byte[] getNTLMv2Blob() {
if (ntlmv2Blob == null) {
ntlmv2Blob = createBlob(getClientChallenge2(), targetInformation, getTimestamp());
}
@@ -512,8 +508,7 @@ final class NTLMEngineImpl implements NTLMEngine {
}
/** Calculate and return LM2 session response */
- public byte[] getLM2SessionResponse()
- throws NTLMEngineException {
+ public byte[] getLM2SessionResponse() {
if (lm2SessionResponse == null) {
final byte[] clntChallenge = getClientChallenge();
lm2SessionResponse = new byte[24];
@@ -600,8 +595,7 @@ final class NTLMEngineImpl implements NTLMEngine {
}
/** Calculates HMAC-MD5 */
- static byte[] hmacMD5(final byte[] value, final byte[] key)
- throws NTLMEngineException {
+ static byte[] hmacMD5(final byte[] value, final byte[] key) {
final HMACMD5 hmacMD5 = new HMACMD5(key);
hmacMD5.update(value);
return hmacMD5.getOutput();
@@ -790,8 +784,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);
@@ -896,17 +889,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];
@@ -932,7 +925,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"
@@ -1076,12 +1069,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;
}
/** NTLM message generation, base class */
@@ -1157,17 +1149,17 @@ final class NTLMEngineImpl implements NTLMEngine {
}
/** Read a ushort from a position within the message buffer */
- int readUShort(final int position) throws NTLMEngineException {
+ int readUShort(final int position) {
return NTLMEngineImpl.readUShort(messageContents, position);
}
/** Read a ulong from a position within the message buffer */
- int readULong(final int position) throws NTLMEngineException {
+ int readULong(final int position) {
return NTLMEngineImpl.readULong(messageContents, position);
}
/** Read a security buffer from a position within the message buffer */
- byte[] readSecurityBuffer(final int position) throws NTLMEngineException {
+ byte[] readSecurityBuffer(final int position) {
return NTLMEngineImpl.readSecurityBuffer(messageContents, position);
}
@@ -1262,11 +1254,11 @@ final class NTLMEngineImpl implements NTLMEngine {
private final byte[] domainBytes;
private final int flags;
- Type1Message(final String domain, final String host) throws NTLMEngineException {
+ Type1Message(final String domain, final String host) {
this(domain, host, null);
}
- Type1Message(final String domain, final String host, final Integer flags) throws NTLMEngineException {
+ Type1Message(final String domain, final String host, final Integer flags) {
super();
this.flags = ((flags == null)?getDefaultFlags():flags);
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpRequestTaskCallable.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpRequestTaskCallable.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpRequestTaskCallable.java
index 6536e14..1e02b2e 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpRequestTaskCallable.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpRequestTaskCallable.java
@@ -107,9 +107,8 @@ class HttpRequestTaskCallable<V> implements Callable<V> {
metrics.getTasks().increment(started);
metrics.getActiveConnections().decrementAndGet();
}
- } else {
- throw new CancellationException();
}
+ throw new CancellationException();
}
public void cancel() {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MainClientExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MainClientExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MainClientExec.java
index 65c71b6..adab87d 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MainClientExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MainClientExec.java
@@ -136,10 +136,9 @@ final class MainClientExec implements ExecChainHandler {
// connection not needed and (assumed to be) in re-usable state
execRuntime.releaseConnection();
return new CloseableHttpResponse(response, null);
- } else {
- ResponseEntityProxy.enchance(response, execRuntime);
- return new CloseableHttpResponse(response, execRuntime);
}
+ ResponseEntityProxy.enchance(response, execRuntime);
+ return new CloseableHttpResponse(response, execRuntime);
} catch (final ConnectionShutdownException ex) {
final InterruptedIOException ioex = new InterruptedIOException(
"Connection has been shut down");
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MinimalHttpClient.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MinimalHttpClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MinimalHttpClient.java
index 0bfc527..d8da21a 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MinimalHttpClient.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MinimalHttpClient.java
@@ -151,10 +151,9 @@ public class MinimalHttpClient extends CloseableHttpClient {
// connection not needed and (assumed to be) in re-usable state
execRuntime.releaseConnection();
return new CloseableHttpResponse(response, null);
- } else {
- ResponseEntityProxy.enchance(response, execRuntime);
- return new CloseableHttpResponse(response, execRuntime);
}
+ ResponseEntityProxy.enchance(response, execRuntime);
+ return new CloseableHttpResponse(response, execRuntime);
} catch (final ConnectionShutdownException ex) {
final InterruptedIOException ioex = new InterruptedIOException("Connection has been shut down");
ioex.initCause(ex);
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RetryExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RetryExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RetryExec.java
index 1f1be4f..7fa9343 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RetryExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RetryExec.java
@@ -113,9 +113,8 @@ final class RetryExec implements ExecChainHandler {
route.getTargetHost().toHostString() + " failed to respond");
updatedex.setStackTrace(ex.getStackTrace());
throw updatedex;
- } else {
- throw ex;
}
+ throw ex;
}
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java
index 100c5d7..c75435d 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/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/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java
index 6b532b7..0d7f9b8 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java
@@ -163,9 +163,8 @@ public class DefaultHttpClientConnectionOperator implements HttpClientConnection
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 new HttpHostConnectException(ex, host, addresses);
}
} catch (final NoRouteToHostException ex) {
if (last) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java
index fb5ae45..8edb551 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java
@@ -239,9 +239,8 @@ public class PoolingHttpClientConnectionManager
private InternalConnectionEndpoint cast(final ConnectionEndpoint endpoint) {
if (endpoint instanceof InternalConnectionEndpoint) {
return (InternalConnectionEndpoint) endpoint;
- } else {
- throw new IllegalStateException("Unexpected endpoint class: " + endpoint.getClass());
}
+ throw new IllegalStateException("Unexpected endpoint class: " + endpoint.getClass());
}
public LeaseRequest lease(final HttpRoute route, final Object state) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/MultihomeIOSessionRequester.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/MultihomeIOSessionRequester.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/MultihomeIOSessionRequester.java
index 51e390a..b07e74b 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/MultihomeIOSessionRequester.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/MultihomeIOSessionRequester.java
@@ -63,66 +63,65 @@ final class MultihomeIOSessionRequester {
final FutureCallback<IOSession> callback) {
if (remoteAddress != null) {
return connectionInitiator.connect(remoteEndpoint, remoteAddress, localAddress, connectTimeout, attachment, callback);
- } else {
- final ComplexFuture<IOSession> future = new ComplexFuture<>(callback);
- final InetAddress[] remoteAddresses;
- try {
- remoteAddresses = dnsResolver.resolve(remoteEndpoint.getHostName());
- } catch (final UnknownHostException ex) {
- future.failed(ex);
- return future;
- }
- final Runnable runnable = new Runnable() {
-
- private final AtomicInteger attempt = new AtomicInteger(0);
-
- void executeNext() {
- final int index = attempt.getAndIncrement();
- final InetSocketAddress remoteAddress = new InetSocketAddress(remoteAddresses[index], remoteEndpoint.getPort());
- final Future<IOSession> sessionFuture = connectionInitiator.connect(
- remoteEndpoint,
- remoteAddress,
- localAddress,
- connectTimeout,
- attachment,
- new FutureCallback<IOSession>() {
-
- @Override
- public void completed(final IOSession session) {
- future.completed(session);
- }
-
- @Override
- public void failed(final Exception cause) {
- if (attempt.get() >= remoteAddresses.length) {
- if (cause instanceof IOException) {
- future.failed(new HttpHostConnectException((IOException) cause, remoteEndpoint, remoteAddresses));
- } else {
- future.failed(cause);
- }
+ }
+ final ComplexFuture<IOSession> future = new ComplexFuture<>(callback);
+ final InetAddress[] remoteAddresses;
+ try {
+ remoteAddresses = dnsResolver.resolve(remoteEndpoint.getHostName());
+ } catch (final UnknownHostException ex) {
+ future.failed(ex);
+ return future;
+ }
+ final Runnable runnable = new Runnable() {
+
+ private final AtomicInteger attempt = new AtomicInteger(0);
+
+ void executeNext() {
+ final int index = attempt.getAndIncrement();
+ final InetSocketAddress remoteAddress = new InetSocketAddress(remoteAddresses[index], remoteEndpoint.getPort());
+ final Future<IOSession> sessionFuture = connectionInitiator.connect(
+ remoteEndpoint,
+ remoteAddress,
+ localAddress,
+ connectTimeout,
+ attachment,
+ new FutureCallback<IOSession>() {
+
+ @Override
+ public void completed(final IOSession session) {
+ future.completed(session);
+ }
+
+ @Override
+ public void failed(final Exception cause) {
+ if (attempt.get() >= remoteAddresses.length) {
+ if (cause instanceof IOException) {
+ future.failed(new HttpHostConnectException((IOException) cause, remoteEndpoint, remoteAddresses));
} else {
- executeNext();
+ future.failed(cause);
}
+ } else {
+ executeNext();
}
+ }
- @Override
- public void cancelled() {
- future.cancel();
- }
+ @Override
+ public void cancelled() {
+ future.cancel();
+ }
- });
- future.setDependency(sessionFuture);
- }
+ });
+ future.setDependency(sessionFuture);
+ }
- @Override
- public void run() {
- executeNext();
- }
+ @Override
+ public void run() {
+ executeNext();
+ }
- };
- runnable.run();
- return future;
- }
+ };
+ runnable.run();
+ return future;
}
public Future<IOSession> connect(
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
index 2080813..00d1d7b 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
@@ -205,9 +205,8 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
private InternalConnectionEndpoint cast(final AsyncConnectionEndpoint endpoint) {
if (endpoint instanceof InternalConnectionEndpoint) {
return (InternalConnectionEndpoint) endpoint;
- } else {
- throw new IllegalStateException("Unexpected endpoint class: " + endpoint.getClass());
}
+ throw new IllegalStateException("Unexpected endpoint class: " + endpoint.getClass());
}
@Override
@@ -540,13 +539,12 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
final ManagedAsyncClientConnection connection = poolEntry.getConnection();
if (connection == null) {
return false;
- } else {
- if (!connection.isOpen()) {
- poolEntry.discardConnection(ShutdownType.IMMEDIATE);
- return false;
- }
- return true;
}
+ if (!connection.isOpen()) {
+ poolEntry.discardConnection(ShutdownType.IMMEDIATE);
+ return false;
+ }
+ return true;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManagerBuilder.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManagerBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManagerBuilder.java
index 63d1d00..b0708e2 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManagerBuilder.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManagerBuilder.java
@@ -188,7 +188,6 @@ public class PoolingAsyncClientConnectionManagerBuilder {
} else {
tlsStrategyCopy = H2TlsStrategy.getDefault();
}
- @SuppressWarnings("resource")
final PoolingAsyncClientConnectionManager poolingmgr = new PoolingAsyncClientConnectionManager(
RegistryBuilder.<TlsStrategy>create()
.register("https", tlsStrategyCopy)
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/io/ManagedHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/io/ManagedHttpClientConnection.java b/httpclient5/src/main/java/org/apache/hc/client5/http/io/ManagedHttpClientConnection.java
index d9b1df7..226947e 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/io/ManagedHttpClientConnection.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/io/ManagedHttpClientConnection.java
@@ -70,6 +70,7 @@ public interface ManagedHttpClientConnection extends HttpClientConnection {
* @return the underlying SSL session if available,
* {@code null} otherwise
*/
+ @Override
SSLSession getSSLSession();
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/HttpClientContext.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/HttpClientContext.java b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/HttpClientContext.java
index 7be4c16..4c35e8f 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/HttpClientContext.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/HttpClientContext.java
@@ -174,7 +174,6 @@ public class HttpClientContext extends HttpCoreContext {
return getAttribute(COOKIE_ORIGIN, CookieOrigin.class);
}
- @SuppressWarnings("unchecked")
private <T> Lookup<T> getLookup(final String name, final Class<T> clazz) {
return getAttribute(name, Lookup.class);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/routing/RoutingSupport.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/routing/RoutingSupport.java b/httpclient5/src/main/java/org/apache/hc/client5/http/routing/RoutingSupport.java
index 946ac14..cd01124 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/routing/RoutingSupport.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/routing/RoutingSupport.java
@@ -47,9 +47,8 @@ public final class RoutingSupport {
throw new ProtocolException("Protocol scheme is not specified");
}
return new HttpHost(authority, scheme);
- } else {
- return null;
}
+ return null;
}
public static HttpHost normalize(final HttpHost host, final SchemePortResolver schemePortResolver) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java
index 25dc62a..7133966 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java
@@ -290,9 +290,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
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestGZip.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestGZip.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestGZip.java
index efdc8de..c38fcbd 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestGZip.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestGZip.java
@@ -41,6 +41,7 @@ import org.apache.hc.core5.http.io.entity.InputStreamEntity;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.ArgumentMatchers;
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(ArgumentMatchers.<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/8d87cf51/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartEntityBuilder.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartEntityBuilder.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartEntityBuilder.java
index e2e8285..16b1271 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartEntityBuilder.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartEntityBuilder.java
@@ -146,7 +146,7 @@ public class TestMultipartEntityBuilder {
}
@Test
public void testMultipartWriteToRFC7578Mode() throws Exception {
- final List<NameValuePair> parameters = new ArrayList<NameValuePair>();
+ final List<NameValuePair> parameters = new ArrayList<>();
parameters.add(new BasicNameValuePair(MIME.FIELD_PARAM_NAME, "test"));
parameters.add(new BasicNameValuePair(MIME.FIELD_PARAM_FILENAME, "hello \u03BA\u03CC\u03C3\u03BC\u03B5!%"));
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestIdleConnectionEvictor.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestIdleConnectionEvictor.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestIdleConnectionEvictor.java
index 87578e8..2c14b39 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestIdleConnectionEvictor.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestIdleConnectionEvictor.java
@@ -33,6 +33,7 @@ import org.apache.hc.core5.pool.ConnPoolControl;
import org.apache.hc.core5.util.TimeValue;
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
/**
@@ -69,7 +70,7 @@ public class TestIdleConnectionEvictor {
Thread.sleep(1000);
Mockito.verify(cm, Mockito.atLeast(1)).closeExpired();
- Mockito.verify(cm, Mockito.never()).closeIdle(Mockito.<TimeValue>any());
+ Mockito.verify(cm, Mockito.never()).closeIdle(ArgumentMatchers.<TimeValue>any());
Assert.assertTrue(connectionEvictor.isRunning());
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java
index b464d9c..e2146cb 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java
@@ -435,7 +435,7 @@ public class TestDigestScheme {
Assert.assertFalse(authscheme.isChallengeComplete());
}
- private static Map<String, String> parseAuthResponse(final String authResponse) throws ParseException {
+ private static Map<String, String> parseAuthResponse(final String authResponse) {
if (!authResponse.startsWith("Digest ")) {
return null;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestSystemDefaultCredentialsProvider.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestSystemDefaultCredentialsProvider.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestSystemDefaultCredentialsProvider.java
index 790ca38..7b75712 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestSystemDefaultCredentialsProvider.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestSystemDefaultCredentialsProvider.java
@@ -38,6 +38,7 @@ import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
/**
@@ -125,11 +126,11 @@ public class TestSystemDefaultCredentialsProvider {
private AuthenticatorDelegate installAuthenticator(final PasswordAuthentication returedAuthentication) {
final AuthenticatorDelegate authenticatorDelegate = Mockito.mock(AuthenticatorDelegate.class);
- Mockito.when(authenticatorDelegate.getPasswordAuthentication(Mockito.anyString(),
- Mockito.<InetAddress>any(), Mockito.anyInt(),
- Mockito.anyString(), Mockito.anyString(),
- Mockito.anyString(), Mockito.<URL>any(),
- Mockito.<RequestorType>any())).thenReturn(returedAuthentication);
+ Mockito.when(authenticatorDelegate.getPasswordAuthentication(ArgumentMatchers.anyString(),
+ ArgumentMatchers.<InetAddress>any(), ArgumentMatchers.anyInt(),
+ ArgumentMatchers.anyString(), ArgumentMatchers.anyString(),
+ ArgumentMatchers.anyString(), ArgumentMatchers.<URL>any(),
+ ArgumentMatchers.<RequestorType>any())).thenReturn(returedAuthentication);
Authenticator.setDefault(new DelegatedAuthenticator(authenticatorDelegate));
return authenticatorDelegate;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCloseableHttpClient.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCloseableHttpClient.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCloseableHttpClient.java
index f75a394..7771f21 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCloseableHttpClient.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCloseableHttpClient.java
@@ -112,7 +112,6 @@ public class TestCloseableHttpClient {
}
@Test
- @SuppressWarnings("unchecked")
public void testExecuteRequestHandleResponse() throws Exception {
final HttpGet httpget = new HttpGet("https://somehost:444/stuff");
@@ -132,7 +131,6 @@ public class TestCloseableHttpClient {
}
@Test(expected=IOException.class)
- @SuppressWarnings("unchecked")
public void testExecuteRequestHandleResponseIOException() throws Exception {
final HttpGet httpget = new HttpGet("https://somehost:444/stuff");
@@ -156,7 +154,6 @@ public class TestCloseableHttpClient {
}
@Test(expected=RuntimeException.class)
- @SuppressWarnings("unchecked")
public void testExecuteRequestHandleResponseHttpException() throws Exception {
final HttpGet httpget = new HttpGet("https://somehost:444/stuff");
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java
index 20b1aa8..c7755fd 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java
@@ -353,7 +353,7 @@ public class TestConnectExec {
};
- };
+ }
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalHttpClient.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalHttpClient.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalHttpClient.java
index 3612ef4..4100a99 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalHttpClient.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalHttpClient.java
@@ -86,7 +86,6 @@ public class TestInternalHttpClient {
private InternalHttpClient client;
- @SuppressWarnings("unchecked")
@Before
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
@@ -165,7 +164,6 @@ public class TestInternalHttpClient {
Assert.assertSame(config, context.getRequestConfig());
}
- @SuppressWarnings("unchecked")
@Test
public void testExecuteLocalContext() throws Exception {
final HttpGet httpget = new HttpGet("http://somehost/stuff");
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java
index b46c9fe..151d0f4 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java
@@ -345,7 +345,7 @@ public class TestMainClientExec {
};
- };
+ }
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java
index 80cca6a..0a53ec7 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java
@@ -112,17 +112,17 @@ public class TestRedirectExec {
response2.setEntity(entity2);
Mockito.when(chain.proceed(
- Mockito.same(request),
- Mockito.<ExecChain.Scope>any())).thenReturn(response1);
+ ArgumentMatchers.same(request),
+ ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response1);
Mockito.when(chain.proceed(
HttpRequestMatcher.matchesRequestUri(redirect),
- Mockito.<ExecChain.Scope>any())).thenReturn(response2);
+ ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response2);
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
redirectExec.execute(request, scope, chain);
final ArgumentCaptor<ClassicHttpRequest> reqCaptor = ArgumentCaptor.forClass(ClassicHttpRequest.class);
- Mockito.verify(chain, Mockito.times(2)).proceed(reqCaptor.capture(), Mockito.same(scope));
+ Mockito.verify(chain, Mockito.times(2)).proceed(reqCaptor.capture(), ArgumentMatchers.same(scope));
final List<ClassicHttpRequest> allValues = reqCaptor.getAllValues();
Assert.assertNotNull(allValues);
@@ -150,7 +150,7 @@ public class TestRedirectExec {
final URI redirect = new URI("http://localhost:80/redirect");
response1.setHeader(HttpHeaders.LOCATION, redirect.toASCIIString());
- Mockito.when(chain.proceed(Mockito.<ClassicHttpRequest>any(), Mockito.<ExecChain.Scope>any())).thenReturn(response1);
+ Mockito.when(chain.proceed(ArgumentMatchers.<ClassicHttpRequest>any(), ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response1);
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
redirectExec.execute(request, scope, chain);
@@ -166,8 +166,8 @@ public class TestRedirectExec {
final URI redirect = new URI("/redirect");
response1.setHeader(HttpHeaders.LOCATION, redirect.toASCIIString());
Mockito.when(chain.proceed(
- Mockito.same(request),
- Mockito.<ExecChain.Scope>any())).thenReturn(response1);
+ ArgumentMatchers.same(request),
+ ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response1);
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
redirectExec.execute(request, scope, chain);
@@ -196,14 +196,14 @@ public class TestRedirectExec {
final ClassicHttpResponse response2 = Mockito.spy(new BasicClassicHttpResponse(HttpStatus.SC_OK));
final HttpHost otherHost = new HttpHost("otherhost", 8888);
Mockito.when(chain.proceed(
- Mockito.same(request),
- Mockito.<ExecChain.Scope>any())).thenReturn(response1);
+ ArgumentMatchers.same(request),
+ ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response1);
Mockito.when(chain.proceed(
HttpRequestMatcher.matchesRequestUri(redirect),
- Mockito.<ExecChain.Scope>any())).thenReturn(response2);
+ ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response2);
Mockito.when(httpRoutePlanner.determineRoute(
- Mockito.eq(otherHost),
- Mockito.<HttpClientContext>any())).thenReturn(new HttpRoute(otherHost));
+ ArgumentMatchers.eq(otherHost),
+ ArgumentMatchers.<HttpClientContext>any())).thenReturn(new HttpRoute(otherHost));
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
redirectExec.execute(request, scope, chain);
@@ -241,16 +241,16 @@ public class TestRedirectExec {
Mockito.when(chain.proceed(
HttpRequestMatcher.matchesRequestUri(uri),
- Mockito.<ExecChain.Scope>any())).thenReturn(response1);
+ ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response1);
Mockito.when(chain.proceed(
HttpRequestMatcher.matchesRequestUri(uri1),
- Mockito.<ExecChain.Scope>any())).thenReturn(response2, response4);
+ ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response2, response4);
Mockito.when(chain.proceed(
HttpRequestMatcher.matchesRequestUri(uri2),
- Mockito.<ExecChain.Scope>any())).thenReturn(response3);
+ ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response3);
Mockito.when(httpRoutePlanner.determineRoute(
- Mockito.eq(new HttpHost("localhost")),
- Mockito.<HttpClientContext>any())).thenReturn(route);
+ ArgumentMatchers.eq(new HttpHost("localhost")),
+ ArgumentMatchers.<HttpClientContext>any())).thenReturn(route);
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
redirectExec.execute(request, scope, chain);
@@ -280,18 +280,18 @@ public class TestRedirectExec {
final ClassicHttpResponse response3 = new BasicClassicHttpResponse(HttpStatus.SC_MOVED_TEMPORARILY);
response3.addHeader("Location", uri1.toASCIIString());
Mockito.when(httpRoutePlanner.determineRoute(
- Mockito.eq(new HttpHost("localhost")),
- Mockito.<HttpClientContext>any())).thenReturn(route);
+ ArgumentMatchers.eq(new HttpHost("localhost")),
+ ArgumentMatchers.<HttpClientContext>any())).thenReturn(route);
Mockito.when(chain.proceed(
HttpRequestMatcher.matchesRequestUri(uri),
- Mockito.<ExecChain.Scope>any())).thenReturn(response1);
+ ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response1);
Mockito.when(chain.proceed(
HttpRequestMatcher.matchesRequestUri(uri1),
- Mockito.<ExecChain.Scope>any())).thenReturn(response2);
+ ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response2);
Mockito.when(chain.proceed(
HttpRequestMatcher.matchesRequestUri(uri2),
- Mockito.<ExecChain.Scope>any())).thenReturn(response3);
+ ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response3);
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
redirectExec.execute(request, scope, chain);
@@ -307,12 +307,12 @@ public class TestRedirectExec {
final URI redirect = new URI("http://localhost:80/redirect");
response1.setHeader(HttpHeaders.LOCATION, redirect.toASCIIString());
Mockito.when(chain.proceed(
- Mockito.same(request),
- Mockito.<ExecChain.Scope>any())).thenReturn(response1);
+ ArgumentMatchers.same(request),
+ ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response1);
Mockito.doThrow(new RuntimeException("Oppsie")).when(redirectStrategy).getLocationURI(
- Mockito.<ClassicHttpRequest>any(),
- Mockito.<ClassicHttpResponse>any(),
- Mockito.<HttpClientContext>any());
+ ArgumentMatchers.<ClassicHttpRequest>any(),
+ ArgumentMatchers.<ClassicHttpResponse>any(),
+ ArgumentMatchers.<HttpClientContext>any());
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
try {
@@ -338,12 +338,12 @@ public class TestRedirectExec {
.build();
response1.setEntity(entity1);
Mockito.when(chain.proceed(
- Mockito.same(request),
- Mockito.<ExecChain.Scope>any())).thenReturn(response1);
+ ArgumentMatchers.same(request),
+ ArgumentMatchers.<ExecChain.Scope>any())).thenReturn(response1);
Mockito.doThrow(new ProtocolException("Oppsie")).when(redirectStrategy).getLocationURI(
- Mockito.<ClassicHttpRequest>any(),
- Mockito.<ClassicHttpResponse>any(),
- Mockito.<HttpClientContext>any());
+ ArgumentMatchers.<ClassicHttpRequest>any(),
+ ArgumentMatchers.<ClassicHttpResponse>any(),
+ ArgumentMatchers.<HttpClientContext>any());
final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, endpoint, context);
try {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestRFC6265CookieSpec.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestRFC6265CookieSpec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestRFC6265CookieSpec.java
index dfdc204..4ee5848 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestRFC6265CookieSpec.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestRFC6265CookieSpec.java
@@ -39,6 +39,7 @@ import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.message.BasicHeader;
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
public class TestRFC6265CookieSpec {
@@ -65,8 +66,8 @@ public class TestRFC6265CookieSpec {
Assert.assertEquals("stuff", cookie.getAttribute("this"));
Assert.assertEquals(null, cookie.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(ArgumentMatchers.<SetCookie>any(), ArgumentMatchers.eq("stuff"));
+ Mockito.verify(h2, Mockito.never()).parse(ArgumentMatchers.<SetCookie>any(), ArgumentMatchers.anyString());
}
@Test
@@ -296,8 +297,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(ArgumentMatchers.<SetCookie>any(), ArgumentMatchers.eq("morestuff"));
+ Mockito.verify(h1, Mockito.times(1)).parse(ArgumentMatchers.<SetCookie>any(), ArgumentMatchers.anyString());
}
@Test
@@ -313,8 +314,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(ArgumentMatchers.<SetCookie>any(), ArgumentMatchers.anyString());
+ Mockito.verify(h2).parse(ArgumentMatchers.<SetCookie>any(), ArgumentMatchers.eq("otherstuff"));
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestHttpClientConnectionOperator.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestHttpClientConnectionOperator.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestHttpClientConnectionOperator.java
index 51ee82e..07c0ac6 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestHttpClientConnectionOperator.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestHttpClientConnectionOperator.java
@@ -64,7 +64,6 @@ public class TestHttpClientConnectionOperator {
private DnsResolver dnsResolver;
private DefaultHttpClientConnectionOperator connectionOperator;
- @SuppressWarnings("unchecked")
@Before
public void setup() throws Exception {
conn = Mockito.mock(ManagedHttpClientConnection.class);
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java
index 579057c..343158f 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java
@@ -53,6 +53,7 @@ import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
public class TestRequestAddCookies {
@@ -345,7 +346,7 @@ public class TestRequestAddCookies {
Assert.assertEquals(1, headers.length);
Assert.assertEquals("name1=value1; name2=value2", headers[0].getValue());
- Mockito.verify(this.cookieStore, Mockito.times(1)).clearExpired(Mockito.<Date>any());
+ Mockito.verify(this.cookieStore, Mockito.times(1)).clearExpired(ArgumentMatchers.<Date>any());
}
@Test
[2/2] httpcomponents-client git commit: Static methods should be
accessed directly. Remove redundant type arguments. Remove exceptions not
thrown from method signatures. Add missing @Override. Remove unnecessary
semicolons. Don't nest unnecessarily.
Posted by gg...@apache.org.
Static methods should be accessed directly. Remove redundant type
arguments. Remove exceptions not thrown from method signatures. Add
missing @Override. Remove unnecessary semicolons. Don't nest
unnecessarily.
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/commit/8d87cf51
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/tree/8d87cf51
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/diff/8d87cf51
Branch: refs/heads/master
Commit: 8d87cf515b324e36355fe4652633fa0e8a7aea92
Parents: 5080210
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 10:40:01 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 4 10:40:01 2018 -0600
----------------------------------------------------------------------
.../http/impl/cache/AsyncCachingExec.java | 16 ++-
.../http/impl/cache/BasicHttpAsyncCache.java | 10 +-
.../hc/client5/http/impl/cache/CachingExec.java | 13 +--
.../http/impl/cache/CachingExecBase.java | 3 +-
.../cache/DefaultAsyncCacheInvalidator.java | 3 +-
.../cache/DefaultAsyncCacheRevalidator.java | 5 +-
.../impl/cache/DefaultCacheInvalidator.java | 3 +-
.../client5/http/impl/cache/FileResource.java | 3 +-
.../client5/http/impl/cache/HeapResource.java | 3 +-
.../MemcachedHttpAsyncCacheStorage.java | 3 +-
.../memcached/MemcachedHttpCacheStorage.java | 3 +-
.../ExponentialBackOffSchedulingStrategy.java | 3 +-
.../http/impl/cache/HttpCacheEntryMatcher.java | 13 +--
...estAbstractSerializingAsyncCacheStorage.java | 111 ++++++++++---------
.../TestAbstractSerializingCacheStorage.java | 23 ++--
.../impl/cache/TestCacheRevalidatorBase.java | 22 ++--
.../http/impl/cache/TestCachingExec.java | 4 +-
.../cache/TestConditionalRequestBuilder.java | 5 +-
.../cache/TestDefaultAsyncCacheInvalidator.java | 105 +++++++++---------
.../impl/cache/TestDefaultCacheInvalidator.java | 4 +-
.../hc/client5/http/osgi/impl/WeakList.java | 9 +-
.../hc/client5/http/osgi/impl/WeakListTest.java | 4 +-
.../AbstractHttpAsyncClientAuthentication.java | 9 +-
.../AbstractHttpAsyncFundamentalsTest.java | 3 +-
...CachingHttpAsyncClientCompatibilityTest.java | 2 +-
.../CachingHttpClientCompatibilityTest.java | 2 +-
.../HttpAsyncClientCompatibilityTest.java | 2 +-
.../external/HttpClientCompatibilityTest.java | 2 +-
.../testing/sync/TestClientAuthentication.java | 12 +-
.../org/apache/hc/client5/http/HttpRoute.java | 3 +-
.../client5/http/async/methods/SimpleBody.java | 7 +-
.../apache/hc/client5/http/auth/AuthScope.java | 3 +-
.../http/entity/DecompressingEntity.java | 3 +-
.../http/entity/mime/FormBodyPartBuilder.java | 2 +-
.../client5/http/entity/mime/MinimalField.java | 2 +-
.../hc/client5/http/impl/AuthSupport.java | 3 +-
.../apache/hc/client5/http/impl/Operations.java | 26 ++---
.../http/impl/async/AsyncConnectExec.java | 14 +--
.../http/impl/async/AsyncProtocolExec.java | 5 +-
.../impl/async/AsyncPushConsumerRegistry.java | 3 +-
.../http/impl/async/AsyncRedirectExec.java | 3 +-
.../Http2AsyncClientEventHandlerFactory.java | 15 ++-
.../HttpAsyncClientEventHandlerFactory.java | 39 ++++---
.../async/InternalHttp2AsyncExecRuntime.java | 55 +++++----
.../async/InternalHttpAsyncExecRuntime.java | 67 ++++++-----
.../client5/http/impl/auth/CredSspScheme.java | 5 +-
.../client5/http/impl/auth/NTLMEngineImpl.java | 58 +++++-----
.../impl/classic/HttpRequestTaskCallable.java | 3 +-
.../http/impl/classic/MainClientExec.java | 5 +-
.../http/impl/classic/MinimalHttpClient.java | 5 +-
.../hc/client5/http/impl/classic/RetryExec.java | 3 +-
.../http/impl/cookie/LaxExpiresHandler.java | 5 +-
.../io/DefaultHttpClientConnectionOperator.java | 3 +-
.../io/PoolingHttpClientConnectionManager.java | 3 +-
.../impl/nio/MultihomeIOSessionRequester.java | 105 +++++++++---------
.../PoolingAsyncClientConnectionManager.java | 14 +--
...lingAsyncClientConnectionManagerBuilder.java | 1 -
.../http/io/ManagedHttpClientConnection.java | 1 +
.../http/protocol/HttpClientContext.java | 1 -
.../hc/client5/http/routing/RoutingSupport.java | 3 +-
.../http/ssl/SSLConnectionSocketFactory.java | 3 +-
.../apache/hc/client5/http/entity/TestGZip.java | 3 +-
.../entity/mime/TestMultipartEntityBuilder.java | 2 +-
.../http/impl/TestIdleConnectionEvictor.java | 3 +-
.../http/impl/auth/TestDigestScheme.java | 2 +-
.../TestSystemDefaultCredentialsProvider.java | 11 +-
.../impl/classic/TestCloseableHttpClient.java | 3 -
.../http/impl/classic/TestConnectExec.java | 2 +-
.../impl/classic/TestInternalHttpClient.java | 2 -
.../http/impl/classic/TestMainClientExec.java | 2 +-
.../http/impl/classic/TestRedirectExec.java | 64 +++++------
.../http/impl/cookie/TestRFC6265CookieSpec.java | 13 ++-
.../io/TestHttpClientConnectionOperator.java | 1 -
.../http/protocol/TestRequestAddCookies.java | 3 +-
74 files changed, 453 insertions(+), 526 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
index f8860c7..f45c1f2 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
@@ -399,13 +399,12 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH
}
}
return Integer.MAX_VALUE;
+ }
+ final AsyncDataConsumer dataConsumer = dataConsumerRef.get();
+ if (dataConsumer != null) {
+ return dataConsumer.consume(src);
} else {
- final AsyncDataConsumer dataConsumer = dataConsumerRef.get();
- if (dataConsumer != null) {
- return dataConsumer.consume(src);
- } else {
- return Integer.MAX_VALUE;
- }
+ return Integer.MAX_VALUE;
}
}
@@ -425,7 +424,7 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH
}
}
- };
+ }
class BackendResponseHandler implements AsyncExecCallback {
@@ -501,9 +500,8 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH
if (cachingDataConsumer != null) {
log.debug("Caching backend response");
return cachingDataConsumer;
- } else {
- return asyncExecCallback.handleResponse(backendResponse, entityDetails);
}
+ return asyncExecCallback.handleResponse(backendResponse, entityDetails);
}
void triggerNewCacheEntryResponse(final HttpResponse backendResponse, final Date responseDate, final ByteArrayBuffer buffer) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java
index a8bb75b..2620da2 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java
@@ -127,10 +127,9 @@ class BasicHttpAsyncCache implements HttpAsyncCache {
}
});
- } else {
- callback.completed(Boolean.TRUE);
- return Operations.nonCancellable();
}
+ callback.completed(Boolean.TRUE);
+ return Operations.nonCancellable();
}
@Override
@@ -150,10 +149,9 @@ class BasicHttpAsyncCache implements HttpAsyncCache {
}
if (!StandardMethods.isSafe(request.getMethod())) {
return cacheInvalidator.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyGenerator, storage, callback);
- } else {
- callback.completed(Boolean.TRUE);
- return Operations.nonCancellable();
}
+ callback.completed(Boolean.TRUE);
+ return Operations.nonCancellable();
}
Cancellable storeInCache(
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
index 66796b4..ebf5b72 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java
@@ -261,10 +261,9 @@ public class CachingExec extends CachingExecBase implements ExecChainHandler {
recordCacheFailure(target, request);
if (!mayCallBackend(request)) {
return convert(generateGatewayTimeout(context), scope);
- } else {
- setResponseStatus(scope.clientContext, CacheResponseStatus.FAILURE);
- return chain.proceed(request, scope);
}
+ setResponseStatus(scope.clientContext, CacheResponseStatus.FAILURE);
+ return chain.proceed(request, scope);
}
} else if (!mayCallBackend(request)) {
log.debug("Cache entry not suitable but only-if-cached requested");
@@ -295,9 +294,8 @@ public class CachingExec extends CachingExecBase implements ExecChainHandler {
});
return convert(response, scope);
- } else {
- return revalidateCacheEntry(target, request, scope, chain, entry);
}
+ return revalidateCacheEntry(target, request, scope, chain, entry);
} catch (final IOException ioex) {
return convert(handleRevalidationFailure(request, context, entry, now), scope);
}
@@ -380,10 +378,9 @@ public class CachingExec extends CachingExecBase implements ExecChainHandler {
if (cacheable) {
storeRequestIfModifiedSinceFor304Response(request, backendResponse);
return cacheAndReturnResponse(target, request, backendResponse, scope, requestDate, responseDate);
- } else {
- log.debug("Backend response is not cacheable");
- responseCache.flushCacheEntriesFor(target, request);
}
+ log.debug("Backend response is not cacheable");
+ responseCache.flushCacheEntriesFor(target, request);
return backendResponse;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java
index 9fd6f56..95f1497 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java
@@ -145,9 +145,8 @@ public class CachingExecBase {
if (fatalError != null && !fatalError.isEmpty()) {
setResponseStatus(context, CacheResponseStatus.CACHE_MODULE_RESPONSE);
return responseGenerator.getErrorForRequest(fatalError.get(0));
- } else {
- return null;
}
+ return null;
}
void recordCacheMiss(final HttpHost target, final HttpRequest request) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheInvalidator.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheInvalidator.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheInvalidator.java
index 6043a54..246a11a 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheInvalidator.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheInvalidator.java
@@ -174,9 +174,8 @@ public class DefaultAsyncCacheInvalidator extends CacheInvalidatorBase implement
if (uri != null && isSameHost(requestUri, uri)) {
removeEntry(storage, cacheKeyResolver.resolve(uri));
return true;
- } else {
- return false;
}
+ return false;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheRevalidator.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheRevalidator.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheRevalidator.java
index fd24741..446dc7a 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheRevalidator.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheRevalidator.java
@@ -51,7 +51,7 @@ class DefaultAsyncCacheRevalidator extends CacheRevalidatorBase {
interface RevalidationCall {
- void execute(AsyncExecCallback asyncExecCallback);;
+ void execute(AsyncExecCallback asyncExecCallback);
}
static class InternalScheduledExecutor implements ScheduledExecutor {
@@ -67,9 +67,8 @@ class DefaultAsyncCacheRevalidator extends CacheRevalidatorBase {
if (timeValue.toMillis() <= 0) {
command.run();
return new Operations.CompletedFuture<Void>(null);
- } else {
- return executor.schedule(command, timeValue);
}
+ return executor.schedule(command, timeValue);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultCacheInvalidator.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultCacheInvalidator.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultCacheInvalidator.java
index 7313080..c305b91 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultCacheInvalidator.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultCacheInvalidator.java
@@ -143,9 +143,8 @@ public class DefaultCacheInvalidator extends CacheInvalidatorBase implements Htt
if (uri != null && isSameHost(requestUri, uri)) {
removeEntry(storage, cacheKeyResolver.resolve(uri));
return true;
- } else {
- return false;
}
+ return false;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/FileResource.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/FileResource.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/FileResource.java
index fa0e2c8..cd240a6 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/FileResource.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/FileResource.java
@@ -92,9 +92,8 @@ public class FileResource extends Resource {
} catch (final FileNotFoundException ex) {
throw new ResourceIOException(ex.getMessage(), ex);
}
- } else {
- throw new ResourceIOException("Resouce already dispoased");
}
+ throw new ResourceIOException("Resouce already dispoased");
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/HeapResource.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/HeapResource.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/HeapResource.java
index 2473205..5c7aab1 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/HeapResource.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/HeapResource.java
@@ -55,9 +55,8 @@ public class HeapResource extends Resource {
final byte[] byteArray = this.arrayRef.get();
if (byteArray != null) {
return byteArray;
- } else {
- throw new ResourceIOException("Resouce already dispoased");
}
+ throw new ResourceIOException("Resouce already dispoased");
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpAsyncCacheStorage.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpAsyncCacheStorage.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpAsyncCacheStorage.java
index b59529d..36d075c 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpAsyncCacheStorage.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpAsyncCacheStorage.java
@@ -150,9 +150,8 @@ public class MemcachedHttpAsyncCacheStorage extends AbstractBinaryAsyncCacheStor
}
if (storageObject instanceof byte[]) {
return (byte[]) storageObject;
- } else {
- throw new ResourceIOException("Unexpected cache content: " + storageObject.getClass());
}
+ throw new ResourceIOException("Unexpected cache content: " + storageObject.getClass());
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpCacheStorage.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpCacheStorage.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpCacheStorage.java
index 7df45b9..dc40e89 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpCacheStorage.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpCacheStorage.java
@@ -145,9 +145,8 @@ public class MemcachedHttpCacheStorage extends AbstractBinaryCacheStorage<CASVal
}
if (storageObject instanceof byte[]) {
return (byte[]) storageObject;
- } else {
- throw new ResourceIOException("Unexpected cache content: " + storageObject.getClass());
}
+ throw new ResourceIOException("Unexpected cache content: " + storageObject.getClass());
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java
index 2bccc9c..ee17f1f 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java
@@ -110,9 +110,8 @@ public class ExponentialBackOffSchedulingStrategy implements SchedulingStrategy
if (consecutiveFailedAttempts > 0) {
final long delay = (long) (initialExpiry.toMillis() * Math.pow(backOffRate, consecutiveFailedAttempts - 1));
return Math.min(delay, maxExpiry.toMillis());
- } else {
- return 0;
}
+ return 0;
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpCacheEntryMatcher.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpCacheEntryMatcher.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpCacheEntryMatcher.java
index 9c4a52c..04ac26f 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpCacheEntryMatcher.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpCacheEntryMatcher.java
@@ -72,13 +72,12 @@ public class HttpCacheEntryMatcher extends BaseMatcher<HttpCacheEntry> {
final Header[] otherHeaders = otherValue.getAllHeaders();
if (expectedHeaders.length != otherHeaders.length) {
return false;
- } else {
- for (int i = 0; i < expectedHeaders.length; i++) {
- final Header h1 = expectedHeaders[i];
- final Header h2 = otherHeaders[i];
- if (!h1.getName().equals(h2.getName()) || !LangUtils.equals(h1.getValue(), h2.getValue())) {
- return false;
- }
+ }
+ for (int i = 0; i < expectedHeaders.length; i++) {
+ final Header h1 = expectedHeaders[i];
+ final Header h2 = otherHeaders[i];
+ if (!h1.getName().equals(h2.getName()) || !LangUtils.equals(h1.getValue(), h2.getValue())) {
+ return false;
}
}
final Resource expectedResource = expectedValue.getResource();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingAsyncCacheStorage.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingAsyncCacheStorage.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingAsyncCacheStorage.java
index 8c0097a..f0b1ad6 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingAsyncCacheStorage.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingAsyncCacheStorage.java
@@ -49,6 +49,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.ArgumentCaptor;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
@@ -87,9 +88,9 @@ public class TestAbstractSerializingAsyncCacheStorage {
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
Mockito.when(impl.store(
- Mockito.eq("bar"),
- Mockito.<byte[]>any(),
- Mockito.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.eq("bar"),
+ ArgumentMatchers.<byte[]>any(),
+ ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -103,7 +104,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
impl.putEntry(key, value, operationCallback);
final ArgumentCaptor<byte[]> argumentCaptor = ArgumentCaptor.forClass(byte[].class);
- Mockito.verify(impl).store(Mockito.eq("bar"), argumentCaptor.capture(), Mockito.<FutureCallback<Boolean>>any());
+ Mockito.verify(impl).store(ArgumentMatchers.eq("bar"), argumentCaptor.capture(), ArgumentMatchers.<FutureCallback<Boolean>>any());
Assert.assertArrayEquals(serialize(key, value), argumentCaptor.getValue());
Mockito.verify(operationCallback).completed(Boolean.TRUE);
}
@@ -113,7 +114,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final String key = "foo";
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
- Mockito.when(impl.restore(Mockito.eq("bar"), Mockito.<FutureCallback<byte[]>>any())).thenAnswer(new Answer<Cancellable>() {
+ Mockito.when(impl.restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -128,7 +129,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final ArgumentCaptor<HttpCacheEntry> argumentCaptor = ArgumentCaptor.forClass(HttpCacheEntry.class);
Mockito.verify(cacheEntryCallback).completed(argumentCaptor.capture());
Assert.assertThat(argumentCaptor.getValue(), CoreMatchers.nullValue());
- Mockito.verify(impl).restore(Mockito.eq("bar"), Mockito.<FutureCallback<byte[]>>any());
+ Mockito.verify(impl).restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any());
}
@Test
@@ -137,7 +138,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final HttpCacheEntry value = HttpTestUtils.makeCacheEntry();
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
- Mockito.when(impl.restore(Mockito.eq("bar"), Mockito.<FutureCallback<byte[]>>any())).thenAnswer(new Answer<Cancellable>() {
+ Mockito.when(impl.restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -153,7 +154,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
Mockito.verify(cacheEntryCallback).completed(argumentCaptor.capture());
final HttpCacheEntry resultingEntry = argumentCaptor.getValue();
Assert.assertThat(resultingEntry, HttpCacheEntryMatcher.equivalent(value));
- Mockito.verify(impl).restore(Mockito.eq("bar"), Mockito.<FutureCallback<byte[]>>any());
+ Mockito.verify(impl).restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any());
}
@Test
@@ -161,7 +162,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final String key = "foo";
final HttpCacheEntry value = HttpTestUtils.makeCacheEntry();
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
- Mockito.when(impl.restore(Mockito.eq("bar"), Mockito.<FutureCallback<byte[]>>any())).thenAnswer(new Answer<Cancellable>() {
+ Mockito.when(impl.restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -176,7 +177,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final ArgumentCaptor<HttpCacheEntry> argumentCaptor = ArgumentCaptor.forClass(HttpCacheEntry.class);
Mockito.verify(cacheEntryCallback).completed(argumentCaptor.capture());
Assert.assertThat(argumentCaptor.getValue(), CoreMatchers.nullValue());
- Mockito.verify(impl).restore(Mockito.eq("bar"), Mockito.<FutureCallback<byte[]>>any());
+ Mockito.verify(impl).restore(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<byte[]>>any());
}
@Test
@@ -185,8 +186,8 @@ public class TestAbstractSerializingAsyncCacheStorage {
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
Mockito.when(impl.delete(
- Mockito.eq("bar"),
- Mockito.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.eq("bar"),
+ ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -208,7 +209,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
- Mockito.when(impl.getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any())).thenAnswer(new Answer<Cancellable>() {
+ Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -219,9 +220,9 @@ public class TestAbstractSerializingAsyncCacheStorage {
});
Mockito.when(impl.store(
- Mockito.eq("bar"),
- Mockito.<byte[]>any(),
- Mockito.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.eq("bar"),
+ ArgumentMatchers.<byte[]>any(),
+ ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -242,8 +243,8 @@ public class TestAbstractSerializingAsyncCacheStorage {
}, operationCallback);
- Mockito.verify(impl).getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any());
- Mockito.verify(impl).store(Mockito.eq("bar"), Mockito.<byte[]>any(), Mockito.<FutureCallback<Boolean>>any());
+ Mockito.verify(impl).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any());
+ Mockito.verify(impl).store(ArgumentMatchers.eq("bar"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
Mockito.verify(operationCallback).completed(Boolean.TRUE);
}
@@ -254,7 +255,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
- Mockito.when(impl.getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any())).thenAnswer(new Answer<Cancellable>() {
+ Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -266,10 +267,10 @@ public class TestAbstractSerializingAsyncCacheStorage {
});
Mockito.when(impl.getStorageObject("stuff")).thenReturn(serialize(key, existingValue));
Mockito.when(impl.updateCAS(
- Mockito.eq("bar"),
- Mockito.eq("stuff"),
- Mockito.<byte[]>any(),
- Mockito.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.eq("bar"),
+ ArgumentMatchers.eq("stuff"),
+ ArgumentMatchers.<byte[]>any(),
+ ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -289,9 +290,9 @@ public class TestAbstractSerializingAsyncCacheStorage {
}, operationCallback);
- Mockito.verify(impl).getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any());
+ Mockito.verify(impl).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any());
Mockito.verify(impl).getStorageObject("stuff");
- Mockito.verify(impl).updateCAS(Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any(), Mockito.<FutureCallback<Boolean>>any());
+ Mockito.verify(impl).updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
Mockito.verify(operationCallback).completed(Boolean.TRUE);
}
@@ -302,7 +303,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
- Mockito.when(impl.getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any())).thenAnswer(
+ Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any())).thenAnswer(
new Answer<Cancellable>() {
@Override
@@ -315,9 +316,9 @@ public class TestAbstractSerializingAsyncCacheStorage {
});
Mockito.when(impl.getStorageObject("stuff")).thenReturn(serialize("not-foo", existingValue));
Mockito.when(impl.store(
- Mockito.eq("bar"),
- Mockito.<byte[]>any(),
- Mockito.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.eq("bar"),
+ ArgumentMatchers.<byte[]>any(),
+ ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -338,11 +339,11 @@ public class TestAbstractSerializingAsyncCacheStorage {
}, operationCallback);
- Mockito.verify(impl).getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any());
+ Mockito.verify(impl).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any());
Mockito.verify(impl).getStorageObject("stuff");
Mockito.verify(impl, Mockito.never()).updateCAS(
- Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any(), Mockito.<FutureCallback<Boolean>>any());
- Mockito.verify(impl).store(Mockito.eq("bar"), Mockito.<byte[]>any(), Mockito.<FutureCallback<Boolean>>any());
+ ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
+ Mockito.verify(impl).store(ArgumentMatchers.eq("bar"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
Mockito.verify(operationCallback).completed(Boolean.TRUE);
}
@@ -353,7 +354,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
- Mockito.when(impl.getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any())).thenAnswer(
+ Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any())).thenAnswer(
new Answer<Cancellable>() {
@Override
@@ -367,10 +368,10 @@ public class TestAbstractSerializingAsyncCacheStorage {
Mockito.when(impl.getStorageObject("stuff")).thenReturn(serialize(key, existingValue));
final AtomicInteger count = new AtomicInteger(0);
Mockito.when(impl.updateCAS(
- Mockito.eq("bar"),
- Mockito.eq("stuff"),
- Mockito.<byte[]>any(),
- Mockito.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.eq("bar"),
+ ArgumentMatchers.eq("stuff"),
+ ArgumentMatchers.<byte[]>any(),
+ ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -394,10 +395,10 @@ public class TestAbstractSerializingAsyncCacheStorage {
}, operationCallback);
- Mockito.verify(impl, Mockito.times(2)).getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any());
+ Mockito.verify(impl, Mockito.times(2)).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any());
Mockito.verify(impl, Mockito.times(2)).getStorageObject("stuff");
Mockito.verify(impl, Mockito.times(2)).updateCAS(
- Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any(), Mockito.<FutureCallback<Boolean>>any());
+ ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
Mockito.verify(operationCallback).completed(Boolean.TRUE);
}
@@ -408,7 +409,7 @@ public class TestAbstractSerializingAsyncCacheStorage {
final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar");
- Mockito.when(impl.getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any())).thenAnswer(
+ Mockito.when(impl.getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any())).thenAnswer(
new Answer<Cancellable>() {
@Override
@@ -422,10 +423,10 @@ public class TestAbstractSerializingAsyncCacheStorage {
Mockito.when(impl.getStorageObject("stuff")).thenReturn(serialize(key, existingValue));
final AtomicInteger count = new AtomicInteger(0);
Mockito.when(impl.updateCAS(
- Mockito.eq("bar"),
- Mockito.eq("stuff"),
- Mockito.<byte[]>any(),
- Mockito.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.eq("bar"),
+ ArgumentMatchers.eq("stuff"),
+ ArgumentMatchers.<byte[]>any(),
+ ArgumentMatchers.<FutureCallback<Boolean>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -449,11 +450,11 @@ public class TestAbstractSerializingAsyncCacheStorage {
}, operationCallback);
- Mockito.verify(impl, Mockito.times(3)).getForUpdateCAS(Mockito.eq("bar"), Mockito.<FutureCallback<String>>any());
+ Mockito.verify(impl, Mockito.times(3)).getForUpdateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.<FutureCallback<String>>any());
Mockito.verify(impl, Mockito.times(3)).getStorageObject("stuff");
Mockito.verify(impl, Mockito.times(3)).updateCAS(
- Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any(), Mockito.<FutureCallback<Boolean>>any());
- Mockito.verify(operationCallback).failed(Mockito.<HttpCacheUpdateException>any());
+ ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any(), ArgumentMatchers.<FutureCallback<Boolean>>any());
+ Mockito.verify(operationCallback).failed(ArgumentMatchers.<HttpCacheUpdateException>any());
}
@Test
@@ -470,8 +471,8 @@ public class TestAbstractSerializingAsyncCacheStorage {
when(impl.digestToStorageKey(key2)).thenReturn(storageKey2);
when(impl.bulkRestore(
- Mockito.<String>anyCollection(),
- Mockito.<FutureCallback<Map<String, byte[]>>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.<String>anyCollection(),
+ ArgumentMatchers.<FutureCallback<Map<String, byte[]>>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -501,8 +502,8 @@ public class TestAbstractSerializingAsyncCacheStorage {
verify(impl, Mockito.times(2)).digestToStorageKey(key1);
verify(impl, Mockito.times(2)).digestToStorageKey(key2);
verify(impl).bulkRestore(
- Mockito.eq(Arrays.asList(storageKey1, storageKey2)),
- Mockito.<FutureCallback<Map<String, byte[]>>>any());
+ ArgumentMatchers.eq(Arrays.asList(storageKey1, storageKey2)),
+ ArgumentMatchers.<FutureCallback<Map<String, byte[]>>>any());
}
@Test
@@ -519,8 +520,8 @@ public class TestAbstractSerializingAsyncCacheStorage {
when(impl.digestToStorageKey(key2)).thenReturn(storageKey2);
when(impl.bulkRestore(
- Mockito.<String>anyCollection(),
- Mockito.<FutureCallback<Map<String, byte[]>>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.<String>anyCollection(),
+ ArgumentMatchers.<FutureCallback<Map<String, byte[]>>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
@@ -550,8 +551,8 @@ public class TestAbstractSerializingAsyncCacheStorage {
verify(impl, Mockito.times(2)).digestToStorageKey(key1);
verify(impl, Mockito.times(2)).digestToStorageKey(key2);
verify(impl).bulkRestore(
- Mockito.eq(Arrays.asList(storageKey1, storageKey2)),
- Mockito.<FutureCallback<Map<String, byte[]>>>any());
+ ArgumentMatchers.eq(Arrays.asList(storageKey1, storageKey2)),
+ ArgumentMatchers.<FutureCallback<Map<String, byte[]>>>any());
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingCacheStorage.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingCacheStorage.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingCacheStorage.java
index a6bb2dc..5fd0b03 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingCacheStorage.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingCacheStorage.java
@@ -46,6 +46,7 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Answers;
import org.mockito.ArgumentCaptor;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -153,7 +154,7 @@ public class TestAbstractSerializingCacheStorage {
});
verify(impl).getForUpdateCAS("bar");
- verify(impl).store(Mockito.eq("bar"), Mockito.<byte[]>any());
+ verify(impl).store(ArgumentMatchers.eq("bar"), ArgumentMatchers.<byte[]>any());
}
@Test
@@ -165,7 +166,7 @@ public class TestAbstractSerializingCacheStorage {
when(impl.digestToStorageKey(key)).thenReturn("bar");
when(impl.getForUpdateCAS("bar")).thenReturn("stuff");
when(impl.getStorageObject("stuff")).thenReturn(serialize(key, existingValue));
- when(impl.updateCAS(Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any())).thenReturn(true);
+ when(impl.updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any())).thenReturn(true);
impl.updateEntry(key, new HttpCacheCASOperation() {
@@ -178,7 +179,7 @@ public class TestAbstractSerializingCacheStorage {
verify(impl).getForUpdateCAS("bar");
verify(impl).getStorageObject("stuff");
- verify(impl).updateCAS(Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any());
+ verify(impl).updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any());
}
@Test
@@ -190,7 +191,7 @@ public class TestAbstractSerializingCacheStorage {
when(impl.digestToStorageKey(key)).thenReturn("bar");
when(impl.getForUpdateCAS("bar")).thenReturn("stuff");
when(impl.getStorageObject("stuff")).thenReturn(serialize("not-foo", existingValue));
- when(impl.updateCAS(Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any())).thenReturn(true);
+ when(impl.updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any())).thenReturn(true);
impl.updateEntry(key, new HttpCacheCASOperation() {
@@ -204,7 +205,7 @@ public class TestAbstractSerializingCacheStorage {
verify(impl).getForUpdateCAS("bar");
verify(impl).getStorageObject("stuff");
- verify(impl).store(Mockito.eq("bar"), Mockito.<byte[]>any());
+ verify(impl).store(ArgumentMatchers.eq("bar"), ArgumentMatchers.<byte[]>any());
}
@Test
@@ -216,7 +217,7 @@ public class TestAbstractSerializingCacheStorage {
when(impl.digestToStorageKey(key)).thenReturn("bar");
when(impl.getForUpdateCAS("bar")).thenReturn("stuff");
when(impl.getStorageObject("stuff")).thenReturn(serialize(key, existingValue));
- when(impl.updateCAS(Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any())).thenReturn(false, true);
+ when(impl.updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any())).thenReturn(false, true);
impl.updateEntry(key, new HttpCacheCASOperation() {
@@ -229,7 +230,7 @@ public class TestAbstractSerializingCacheStorage {
verify(impl, Mockito.times(2)).getForUpdateCAS("bar");
verify(impl, Mockito.times(2)).getStorageObject("stuff");
- verify(impl, Mockito.times(2)).updateCAS(Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any());
+ verify(impl, Mockito.times(2)).updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any());
}
@Test
@@ -241,7 +242,7 @@ public class TestAbstractSerializingCacheStorage {
when(impl.digestToStorageKey(key)).thenReturn("bar");
when(impl.getForUpdateCAS("bar")).thenReturn("stuff");
when(impl.getStorageObject("stuff")).thenReturn(serialize(key, existingValue));
- when(impl.updateCAS(Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any())).thenReturn(false, false, false, true);
+ when(impl.updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any())).thenReturn(false, false, false, true);
try {
impl.updateEntry(key, new HttpCacheCASOperation() {
@@ -258,7 +259,7 @@ public class TestAbstractSerializingCacheStorage {
verify(impl, Mockito.times(3)).getForUpdateCAS("bar");
verify(impl, Mockito.times(3)).getStorageObject("stuff");
- verify(impl, Mockito.times(3)).updateCAS(Mockito.eq("bar"), Mockito.eq("stuff"), Mockito.<byte[]>any());
+ verify(impl, Mockito.times(3)).updateCAS(ArgumentMatchers.eq("bar"), ArgumentMatchers.eq("stuff"), ArgumentMatchers.<byte[]>any());
}
@Test
@@ -273,7 +274,7 @@ public class TestAbstractSerializingCacheStorage {
when(impl.digestToStorageKey(key1)).thenReturn(storageKey1);
when(impl.digestToStorageKey(key2)).thenReturn(storageKey2);
- when(impl.bulkRestore(Mockito.<String>anyCollection())).thenAnswer(new Answer<Map<String, byte[]>>() {
+ when(impl.bulkRestore(ArgumentMatchers.<String>anyCollection())).thenAnswer(new Answer<Map<String, byte[]>>() {
@Override
public Map<String, byte[]> answer(final InvocationOnMock invocation) throws Throwable {
@@ -311,7 +312,7 @@ public class TestAbstractSerializingCacheStorage {
when(impl.digestToStorageKey(key1)).thenReturn(storageKey1);
when(impl.digestToStorageKey(key2)).thenReturn(storageKey2);
- when(impl.bulkRestore(Mockito.<String>anyCollection())).thenAnswer(new Answer<Map<String, byte[]>>() {
+ when(impl.bulkRestore(ArgumentMatchers.<String>anyCollection())).thenAnswer(new Answer<Map<String, byte[]>>() {
@Override
public Map<String, byte[]> answer(final InvocationOnMock invocation) throws Throwable {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheRevalidatorBase.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheRevalidatorBase.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheRevalidatorBase.java
index 0326aba..f4dd4c5 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheRevalidatorBase.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheRevalidatorBase.java
@@ -44,8 +44,8 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
@@ -68,26 +68,26 @@ public class TestCacheRevalidatorBase {
@Test
public void testRevalidateCacheEntrySchedulesExecutionAndPopulatesIdentifier() {
- when(mockSchedulingStrategy.schedule(Mockito.anyInt())).thenReturn(TimeValue.ofSeconds(1));
+ when(mockSchedulingStrategy.schedule(ArgumentMatchers.anyInt())).thenReturn(TimeValue.ofSeconds(1));
final String cacheKey = "blah";
impl.scheduleRevalidation(cacheKey, mockOperation);
verify(mockSchedulingStrategy).schedule(0);
- verify(mockScheduledExecutor).schedule(Mockito.same(mockOperation), Mockito.eq(TimeValue.ofSeconds(1)));
+ verify(mockScheduledExecutor).schedule(ArgumentMatchers.same(mockOperation), ArgumentMatchers.eq(TimeValue.ofSeconds(1)));
Assert.assertEquals(1, impl.getScheduledIdentifiers().size());
}
@Test
public void testMarkCompleteRemovesIdentifier() {
- when(mockSchedulingStrategy.schedule(Mockito.anyInt())).thenReturn(TimeValue.ofSeconds(3));
+ when(mockSchedulingStrategy.schedule(ArgumentMatchers.anyInt())).thenReturn(TimeValue.ofSeconds(3));
final String cacheKey = "blah";
impl.scheduleRevalidation(cacheKey, mockOperation);
verify(mockSchedulingStrategy).schedule(0);
- verify(mockScheduledExecutor).schedule(Mockito.<Runnable>any(), Mockito.eq(TimeValue.ofSeconds(3)));
+ verify(mockScheduledExecutor).schedule(ArgumentMatchers.<Runnable>any(), ArgumentMatchers.eq(TimeValue.ofSeconds(3)));
Assert.assertEquals(1, impl.getScheduledIdentifiers().size());
Assert.assertTrue(impl.getScheduledIdentifiers().contains(cacheKey));
@@ -99,27 +99,27 @@ public class TestCacheRevalidatorBase {
@Test
public void testRevalidateCacheEntryDoesNotPopulateIdentifierOnRejectedExecutionException() {
- when(mockSchedulingStrategy.schedule(Mockito.anyInt())).thenReturn(TimeValue.ofSeconds(2));
- doThrow(new RejectedExecutionException()).when(mockScheduledExecutor).schedule(Mockito.<Runnable>any(), Mockito.<TimeValue>any());
+ when(mockSchedulingStrategy.schedule(ArgumentMatchers.anyInt())).thenReturn(TimeValue.ofSeconds(2));
+ doThrow(new RejectedExecutionException()).when(mockScheduledExecutor).schedule(ArgumentMatchers.<Runnable>any(), ArgumentMatchers.<TimeValue>any());
final String cacheKey = "blah";
impl.scheduleRevalidation(cacheKey, mockOperation);
Assert.assertEquals(0, impl.getScheduledIdentifiers().size());
- verify(mockScheduledExecutor).schedule(Mockito.<Runnable>any(), Mockito.eq(TimeValue.ofSeconds(2)));
+ verify(mockScheduledExecutor).schedule(ArgumentMatchers.<Runnable>any(), ArgumentMatchers.eq(TimeValue.ofSeconds(2)));
}
@Test
public void testRevalidateCacheEntryProperlyCollapsesRequest() {
- when(mockSchedulingStrategy.schedule(Mockito.anyInt())).thenReturn(TimeValue.ofSeconds(2));
+ when(mockSchedulingStrategy.schedule(ArgumentMatchers.anyInt())).thenReturn(TimeValue.ofSeconds(2));
final String cacheKey = "blah";
impl.scheduleRevalidation(cacheKey, mockOperation);
impl.scheduleRevalidation(cacheKey, mockOperation);
impl.scheduleRevalidation(cacheKey, mockOperation);
- verify(mockSchedulingStrategy).schedule(Mockito.anyInt());
- verify(mockScheduledExecutor).schedule(Mockito.<Runnable>any(), Mockito.eq(TimeValue.ofSeconds(2)));
+ verify(mockSchedulingStrategy).schedule(ArgumentMatchers.anyInt());
+ verify(mockScheduledExecutor).schedule(ArgumentMatchers.<Runnable>any(), ArgumentMatchers.eq(TimeValue.ofSeconds(2)));
Assert.assertEquals(1, impl.getScheduledIdentifiers().size());
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExec.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExec.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExec.java
index 95969a3..c001396 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExec.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExec.java
@@ -415,11 +415,11 @@ public class TestCachingExec extends TestCachingExecChain {
return EasyMock.expect(resp).andReturn(response);
}
- private void getVariantCacheEntriesReturns(final Map<String,Variant> result) throws IOException {
+ private void getVariantCacheEntriesReturns(final Map<String,Variant> result) {
expect(mockCache.getVariantCacheEntriesWithEtags(host, request)).andReturn(result);
}
- private void cacheInvalidatorWasCalled() throws IOException {
+ private void cacheInvalidatorWasCalled() {
mockCache.flushCacheEntriesInvalidatedByRequest((HttpHost)anyObject(), (HttpRequest)anyObject());
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java
index 3592f65..8fb62f7 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java
@@ -38,7 +38,6 @@ import org.apache.hc.client5.http.utils.DateUtils;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HeaderElement;
import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.hc.core5.http.message.MessageSupport;
@@ -58,7 +57,7 @@ public class TestConditionalRequestBuilder {
}
@Test
- public void testBuildConditionalRequestWithLastModified() throws ProtocolException {
+ public void testBuildConditionalRequestWithLastModified() {
final String theMethod = "GET";
final String theUri = "/theuri";
final String lastModified = "this is my last modified date";
@@ -111,7 +110,7 @@ public class TestConditionalRequestBuilder {
}
@Test
- public void testBuildConditionalRequestWithETag() throws ProtocolException {
+ public void testBuildConditionalRequestWithETag() {
final String theMethod = "GET";
final String theUri = "/theuri";
final String theETag = "this is my eTag";
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultAsyncCacheInvalidator.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultAsyncCacheInvalidator.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultAsyncCacheInvalidator.java
index 5845d36..73660e9 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultAsyncCacheInvalidator.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultAsyncCacheInvalidator.java
@@ -52,6 +52,7 @@ import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
@@ -82,7 +83,7 @@ public class TestDefaultAsyncCacheInvalidator {
now = new Date();
tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
- when(cacheKeyResolver.resolve(Mockito.<URI>any())).thenAnswer(new Answer<String>() {
+ when(cacheKeyResolver.resolve(ArgumentMatchers.<URI>any())).thenAnswer(new Answer<String>() {
@Override
public String answer(final InvocationOnMock invocation) throws Throwable {
@@ -109,8 +110,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
verify(mockEntry).getVariantMap();
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -130,9 +131,9 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
verify(mockEntry).getVariantMap();
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
- verify(mockStorage).removeEntry(Mockito.eq("http://foo.example.com:80/content"), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq("http://foo.example.com:80/content"), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -152,9 +153,9 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
verify(mockEntry).getVariantMap();
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
- verify(mockStorage).removeEntry(Mockito.eq("http://foo.example.com:80/content"), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq("http://foo.example.com:80/content"), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -174,9 +175,9 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
verify(mockEntry).getVariantMap();
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
- verify(mockStorage).removeEntry(Mockito.eq("http://foo.example.com:80/content"), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq("http://foo.example.com:80/content"), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -196,8 +197,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
verify(mockEntry).getVariantMap();
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -205,7 +206,7 @@ public class TestDefaultAsyncCacheInvalidator {
final HttpRequest request = new BasicHttpRequest("GET","/");
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq("http://foo.example.com:80/"), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq("http://foo.example.com:80/"), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -214,7 +215,7 @@ public class TestDefaultAsyncCacheInvalidator {
final HttpRequest request = new BasicHttpRequest("HEAD","/");
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq("http://foo.example.com:80/"), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq("http://foo.example.com:80/"), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -232,8 +233,8 @@ public class TestDefaultAsyncCacheInvalidator {
verify(mockEntry).getRequestMethod();
verify(mockEntry).getVariantMap();
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -253,9 +254,9 @@ public class TestDefaultAsyncCacheInvalidator {
verify(mockEntry).getRequestMethod();
verify(mockEntry).getVariantMap();
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
- verify(mockStorage).removeEntry(Mockito.eq(theVariantURI), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(theVariantURI), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -268,7 +269,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -282,7 +283,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -298,7 +299,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
verify(mockEntry).getRequestMethod();
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -309,7 +310,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq("http://foo.example.com:80/"), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq("http://foo.example.com:80/"), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -320,7 +321,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq("http://foo.example.com:80/"), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq("http://foo.example.com:80/"), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -337,10 +338,10 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByRequest(host, request, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verify(mockEntry).getVariantMap();
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
- verify(mockStorage).removeEntry(Mockito.eq(variantUri), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(variantUri), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -370,8 +371,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -392,8 +393,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -428,8 +429,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -450,8 +451,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
}
@Test
@@ -492,7 +493,7 @@ public class TestDefaultAsyncCacheInvalidator {
cacheReturnsEntryForUri(key, entry);
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -514,7 +515,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -531,7 +532,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -553,7 +554,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -574,7 +575,7 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -596,8 +597,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -618,8 +619,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -641,8 +642,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -664,8 +665,8 @@ public class TestDefaultAsyncCacheInvalidator {
impl.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyResolver, mockStorage, operationCallback);
- verify(mockStorage).getEntry(Mockito.eq(key), Mockito.<FutureCallback<HttpCacheEntry>>any());
- verify(mockStorage).removeEntry(Mockito.eq(key), Mockito.<FutureCallback<Boolean>>any());
+ verify(mockStorage).getEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any());
+ verify(mockStorage).removeEntry(ArgumentMatchers.eq(key), ArgumentMatchers.<FutureCallback<Boolean>>any());
verifyNoMoreInteractions(mockStorage);
}
@@ -677,8 +678,8 @@ public class TestDefaultAsyncCacheInvalidator {
private void cacheReturnsEntryForUri(final String key, final HttpCacheEntry cacheEntry) {
Mockito.when(mockStorage.getEntry(
- Mockito.eq(key),
- Mockito.<FutureCallback<HttpCacheEntry>>any())).thenAnswer(new Answer<Cancellable>() {
+ ArgumentMatchers.eq(key),
+ ArgumentMatchers.<FutureCallback<HttpCacheEntry>>any())).thenAnswer(new Answer<Cancellable>() {
@Override
public Cancellable answer(final InvocationOnMock invocation) throws Throwable {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultCacheInvalidator.java
----------------------------------------------------------------------
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultCacheInvalidator.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultCacheInvalidator.java
index 45ea326..1d2dee9 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultCacheInvalidator.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestDefaultCacheInvalidator.java
@@ -51,8 +51,8 @@ import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
@@ -77,7 +77,7 @@ public class TestDefaultCacheInvalidator {
now = new Date();
tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
- when(cacheKeyResolver.resolve(Mockito.<URI>any())).thenAnswer(new Answer<String>() {
+ when(cacheKeyResolver.resolve(ArgumentMatchers.<URI>any())).thenAnswer(new Answer<String>() {
@Override
public String answer(final InvocationOnMock invocation) throws Throwable {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/WeakList.java
----------------------------------------------------------------------
diff --git a/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/WeakList.java b/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/WeakList.java
index 77b3dc7..815bc04 100644
--- a/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/WeakList.java
+++ b/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/WeakList.java
@@ -43,7 +43,7 @@ class WeakList<T> extends AbstractList<T> {
private final List<WeakReference<T>> innerList;
public WeakList() {
- this.innerList = new ArrayList<WeakReference<T>>();
+ this.innerList = new ArrayList<>();
}
@Override
@@ -59,7 +59,7 @@ class WeakList<T> extends AbstractList<T> {
@Override
public boolean add(final T t) {
- return innerList.add(new WeakReference<T>(t));
+ return innerList.add(new WeakReference<>(t));
}
@Override
@@ -79,7 +79,7 @@ class WeakList<T> extends AbstractList<T> {
@Override
public Iterator<T> iterator() {
- return new WeakIterator<T>(innerList.iterator());
+ return new WeakIterator<>(innerList.iterator());
}
private class WeakIterator<T> implements Iterator<T> {
@@ -104,9 +104,8 @@ class WeakList<T> extends AbstractList<T> {
final T result = next.get();
fetchNext();
return result;
- } else {
- throw new NoSuchElementException();
}
+ throw new NoSuchElementException();
}
private void fetchNext() {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/WeakListTest.java
----------------------------------------------------------------------
diff --git a/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/WeakListTest.java b/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/WeakListTest.java
index a28e09c..ff0f9c7 100644
--- a/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/WeakListTest.java
+++ b/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/WeakListTest.java
@@ -39,7 +39,7 @@ public class WeakListTest {
@Test
public void testWeakList() {
- final WeakList<Object> list = new WeakList<Object>();
+ final WeakList<Object> list = new WeakList<>();
list.add("hello");
list.add(null);
@@ -61,7 +61,7 @@ public class WeakListTest {
@Test
public void clearSupported() {
- final WeakList<Object> list = new WeakList<Object>();
+ final WeakList<Object> list = new WeakList<>();
list.add("hello");
assertEquals(1, list.size());
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java
index 611c660..817fb50 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthentication.java
@@ -477,14 +477,9 @@ public abstract class AbstractHttpAsyncClientAuthentication<T extends CloseableH
public boolean authenticate(final URIAuthority authority, final String requestUri, final String credentials) {
final boolean authenticated = super.authenticate(authority, requestUri, credentials);
if (authenticated) {
- if (this.count.incrementAndGet() % 4 != 0) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
+ return this.count.incrementAndGet() % 4 != 0;
}
+ return false;
}
};
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java
index 4070d7f..3100812 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java
@@ -196,9 +196,8 @@ public abstract class AbstractHttpAsyncFundamentalsTest<T extends CloseableHttpA
final SimpleHttpResponse response = resultQueue.poll();
if (response == null) {
break;
- } else {
- Assert.assertThat(response.getCode(), CoreMatchers.equalTo(200));
}
+ Assert.assertThat(response.getCode(), CoreMatchers.equalTo(200));
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpAsyncClientCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpAsyncClientCompatibilityTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpAsyncClientCompatibilityTest.java
index 2d6de60..3302c51 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpAsyncClientCompatibilityTest.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpAsyncClientCompatibilityTest.java
@@ -108,7 +108,7 @@ public class CachingHttpAsyncClientCompatibilityTest {
client.close();
}
- enum TestResult {OK, NOK};
+ enum TestResult {OK, NOK}
private void logResult(final TestResult result, final HttpRequest request, final String message) {
final StringBuilder buf = new StringBuilder();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpClientCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpClientCompatibilityTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpClientCompatibilityTest.java
index 4b9b0ef..ee3ba86 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpClientCompatibilityTest.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpClientCompatibilityTest.java
@@ -95,7 +95,7 @@ public class CachingHttpClientCompatibilityTest {
client.close();
}
- enum TestResult {OK, NOK};
+ enum TestResult {OK, NOK}
private void logResult(final TestResult result, final HttpRequest request, final String message) {
final StringBuilder buf = new StringBuilder();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/8d87cf51/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java
index cbeba3a..f0eb887 100644
--- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java
+++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java
@@ -140,7 +140,7 @@ public class HttpAsyncClientCompatibilityTest {
client.close();
}
- enum TestResult {OK, NOK};
+ enum TestResult {OK, NOK}
private void logResult(final TestResult result, final HttpRequest request, final String message) {
final StringBuilder buf = new StringBuilder();