Skip to content

Commit 78ef5cf

Browse files
committed
Implement ProxyPartitionKey equals and hashcode, close AsyncHttpClient#1079
1 parent c9e31e2 commit 78ef5cf

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

client/src/main/java/org/asynchttpclient/channel/ChannelPoolPartitioning.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,43 @@ public ProxyPartitionKey(String proxyHost, int proxyPort, boolean secured, Strin
3131
this.targetHostBaseUrl = targetHostBaseUrl;
3232
}
3333

34+
@Override
35+
public int hashCode() {
36+
final int prime = 31;
37+
int result = 1;
38+
result = prime * result + ((proxyHost == null) ? 0 : proxyHost.hashCode());
39+
result = prime * result + proxyPort;
40+
result = prime * result + (secured ? 1231 : 1237);
41+
result = prime * result + ((targetHostBaseUrl == null) ? 0 : targetHostBaseUrl.hashCode());
42+
return result;
43+
}
44+
45+
@Override
46+
public boolean equals(Object obj) {
47+
if (this == obj)
48+
return true;
49+
if (obj == null)
50+
return false;
51+
if (getClass() != obj.getClass())
52+
return false;
53+
ProxyPartitionKey other = (ProxyPartitionKey) obj;
54+
if (proxyHost == null) {
55+
if (other.proxyHost != null)
56+
return false;
57+
} else if (!proxyHost.equals(other.proxyHost))
58+
return false;
59+
if (proxyPort != other.proxyPort)
60+
return false;
61+
if (secured != other.secured)
62+
return false;
63+
if (targetHostBaseUrl == null) {
64+
if (other.targetHostBaseUrl != null)
65+
return false;
66+
} else if (!targetHostBaseUrl.equals(other.targetHostBaseUrl))
67+
return false;
68+
return true;
69+
}
70+
3471
@Override
3572
public String toString() {
3673
return new StringBuilder()//

0 commit comments

Comments
 (0)