You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2022/11/14 21:15:52 UTC
[httpcomponents-client] branch master updated (290ec2202 -> 0bbbeb7d1)
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
from 290ec2202 Fix compiler warnings in tests
new 074eca878 Deprecated LangUtils#hashCode() in favor of Objects.hash() and Objects.hashCode()
new 0bbbeb7d1 Cancel connection request on exception
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
RELEASE_NOTES.txt | 3 +++
.../main/java/org/apache/hc/client5/http/HttpRoute.java | 14 +-------------
.../java/org/apache/hc/client5/http/RouteTracker.java | 15 +--------------
.../java/org/apache/hc/client5/http/auth/AuthScope.java | 9 +--------
.../apache/hc/client5/http/auth/BasicUserPrincipal.java | 5 +----
.../org/apache/hc/client5/http/auth/NTCredentials.java | 7 +------
.../org/apache/hc/client5/http/auth/NTUserPrincipal.java | 6 +-----
.../apache/hc/client5/http/impl/auth/BasicAuthCache.java | 8 +-------
.../hc/client5/http/impl/classic/InternalExecRuntime.java | 3 +++
9 files changed, 13 insertions(+), 57 deletions(-)
[httpcomponents-client] 01/02: Deprecated LangUtils#hashCode() in favor of Objects.hash() and Objects.hashCode()
Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
commit 074eca8782dd3ffc836f193dc14882f84d42610c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 14 10:21:26 2022 -0500
Deprecated LangUtils#hashCode() in favor of Objects.hash() and
Objects.hashCode()
---
RELEASE_NOTES.txt | 3 +++
.../main/java/org/apache/hc/client5/http/HttpRoute.java | 14 +-------------
.../java/org/apache/hc/client5/http/RouteTracker.java | 15 +--------------
.../java/org/apache/hc/client5/http/auth/AuthScope.java | 9 +--------
.../apache/hc/client5/http/auth/BasicUserPrincipal.java | 5 +----
.../org/apache/hc/client5/http/auth/NTCredentials.java | 7 +------
.../org/apache/hc/client5/http/auth/NTUserPrincipal.java | 6 +-----
.../apache/hc/client5/http/impl/auth/BasicAuthCache.java | 8 +-------
8 files changed, 10 insertions(+), 57 deletions(-)
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index f892daba4..de896b735 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -12,6 +12,9 @@ Change Log
* Replace deprecated use of LangUtils#equals() with Objects.equals().
Contributed by Gary Gregory <ggregory at apache.org>
+* Deprecated LangUtils#hashCode() in favor of Objects.hash() and Objects.hashCode().
+ Contributed by Gary Gregory <ggregory at apache.org>
+
Release 5.2
------------------
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 ad2cf77e1..54294a1a8 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
@@ -39,7 +39,6 @@ import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.LangUtils;
/**
* Connection route definition for HTTP requests.
@@ -281,18 +280,7 @@ public final class HttpRoute implements RouteInfo, Cloneable {
*/
@Override
public int hashCode() {
- int hash = LangUtils.HASH_SEED;
- hash = LangUtils.hashCode(hash, this.targetHost);
- hash = LangUtils.hashCode(hash, this.localAddress);
- if (this.proxyChain != null) {
- for (final HttpHost element : this.proxyChain) {
- hash = LangUtils.hashCode(hash, element);
- }
- }
- hash = LangUtils.hashCode(hash, this.secure);
- hash = LangUtils.hashCode(hash, this.tunnelled);
- hash = LangUtils.hashCode(hash, this.layered);
- return hash;
+ return Objects.hash(targetHost, localAddress, proxyChain, secure, tunnelled, layered);
}
/**
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/RouteTracker.java b/httpclient5/src/main/java/org/apache/hc/client5/http/RouteTracker.java
index 0ebfb1dbc..0aa83fc89 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/RouteTracker.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/RouteTracker.java
@@ -33,7 +33,6 @@ import java.util.Objects;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.Asserts;
-import org.apache.hc.core5.util.LangUtils;
/**
* Helps tracking the steps in establishing a route.
@@ -310,19 +309,7 @@ public final class RouteTracker implements RouteInfo, Cloneable {
*/
@Override
public int hashCode() {
- int hash = LangUtils.HASH_SEED;
- hash = LangUtils.hashCode(hash, this.targetHost);
- hash = LangUtils.hashCode(hash, this.localAddress);
- if (this.proxyChain != null) {
- for (final HttpHost element : this.proxyChain) {
- hash = LangUtils.hashCode(hash, element);
- }
- }
- hash = LangUtils.hashCode(hash, this.connected);
- hash = LangUtils.hashCode(hash, this.secure);
- hash = LangUtils.hashCode(hash, this.tunnelled);
- hash = LangUtils.hashCode(hash, this.layered);
- return hash;
+ return Objects.hash(targetHost, localAddress, connected, proxyChain, secure, tunnelled, layered);
}
/**
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 312e5b861..2f8b80764 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
@@ -33,7 +33,6 @@ import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.LangUtils;
/**
* {@code AuthScope} represents an authentication scope consisting of
@@ -225,13 +224,7 @@ public class AuthScope {
@Override
public int hashCode() {
- int hash = LangUtils.HASH_SEED;
- hash = LangUtils.hashCode(hash, this.protocol);
- hash = LangUtils.hashCode(hash, this.host);
- hash = LangUtils.hashCode(hash, this.port);
- hash = LangUtils.hashCode(hash, this.realm);
- hash = LangUtils.hashCode(hash, toNullSafeLowerCase(this.schemeName));
- return hash;
+ return Objects.hash(protocol, host, port, realm, toNullSafeLowerCase(this.schemeName));
}
private String toNullSafeLowerCase(final String str) {
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/BasicUserPrincipal.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/BasicUserPrincipal.java
index 980259d4c..e14e3935c 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/BasicUserPrincipal.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/BasicUserPrincipal.java
@@ -33,7 +33,6 @@ import java.util.Objects;
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.LangUtils;
/**
* Basic username based principal representation.
@@ -60,9 +59,7 @@ public final class BasicUserPrincipal implements Principal, Serializable {
@Override
public int hashCode() {
- int hash = LangUtils.HASH_SEED;
- hash = LangUtils.hashCode(hash, this.username);
- return hash;
+ return Objects.hashCode(username);
}
@Override
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java
index a92f49042..29e70e1cc 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java
@@ -34,7 +34,6 @@ import java.util.Objects;
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.LangUtils;
/**
* Microsoft Windows specific {@link Credentials} representation that includes
@@ -146,11 +145,7 @@ public class NTCredentials implements Credentials, Serializable {
@Override
public int hashCode() {
- int hash = LangUtils.HASH_SEED;
- hash = LangUtils.hashCode(hash, this.principal);
- hash = LangUtils.hashCode(hash, this.workstation);
- hash = LangUtils.hashCode(hash, this.netbiosDomain);
- return hash;
+ return Objects.hash(principal, workstation, netbiosDomain);
}
@Override
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTUserPrincipal.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTUserPrincipal.java
index 225b6eaf2..000b16f45 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTUserPrincipal.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTUserPrincipal.java
@@ -34,7 +34,6 @@ import java.util.Objects;
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.LangUtils;
/**
* Microsoft Windows specific user principal implementation.
@@ -87,10 +86,7 @@ public class NTUserPrincipal implements Principal, Serializable {
@Override
public int hashCode() {
- int hash = LangUtils.HASH_SEED;
- hash = LangUtils.hashCode(hash, this.username);
- hash = LangUtils.hashCode(hash, this.domain);
- return hash;
+ return Objects.hash(username, domain);
}
@Override
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/BasicAuthCache.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/BasicAuthCache.java
index 7450a401f..574f69b3f 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/BasicAuthCache.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/BasicAuthCache.java
@@ -46,7 +46,6 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.net.NamedEndpoint;
import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.LangUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -98,12 +97,7 @@ public class BasicAuthCache implements AuthCache {
@Override
public int hashCode() {
- int hash = LangUtils.HASH_SEED;
- hash = LangUtils.hashCode(hash, this.scheme);
- hash = LangUtils.hashCode(hash, this.host);
- hash = LangUtils.hashCode(hash, this.port);
- hash = LangUtils.hashCode(hash, this.pathPrefix);
- return hash;
+ return Objects.hash(scheme, host, port, pathPrefix);
}
@Override
[httpcomponents-client] 02/02: Cancel connection request on exception
Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
commit 0bbbeb7d15626cb72f304712871ce19a299d3316
Author: Bryan Keller <br...@gmail.com>
AuthorDate: Mon Nov 14 07:54:48 2022 -0800
Cancel connection request on exception
---
.../org/apache/hc/client5/http/impl/classic/InternalExecRuntime.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalExecRuntime.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalExecRuntime.java
index 9e7a8ebb6..a3d5b6f2d 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalExecRuntime.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalExecRuntime.java
@@ -116,11 +116,14 @@ class InternalExecRuntime implements ExecRuntime, Cancellable {
log.debug("{} acquired endpoint {}", id, ConnPoolSupport.getId(connectionEndpoint));
}
} catch(final TimeoutException ex) {
+ connRequest.cancel();
throw new ConnectionRequestTimeoutException(ex.getMessage());
} catch(final InterruptedException interrupted) {
+ connRequest.cancel();
Thread.currentThread().interrupt();
throw new RequestFailedException("Request aborted", interrupted);
} catch(final ExecutionException ex) {
+ connRequest.cancel();
Throwable cause = ex.getCause();
if (cause == null) {
cause = ex;