@@ -33,19 +33,12 @@ enum PerHostChannelPoolPartitioning implements ChannelPoolPartitioning {
3333
3434 @ Override
3535 public Object getPartitionKey (Uri uri , @ Nullable String virtualHost , @ Nullable ProxyServer proxyServer ) {
36+ if (proxyServer == null && virtualHost == null ) {
37+ return new PartitionKey (uri .getScheme (), uri .getHost (), uri .getExplicitPort ());
38+ }
39+
3640 String targetHostBaseUrl = uri .getBaseUrl ();
37- if (proxyServer == null ) {
38- if (virtualHost == null ) {
39- return targetHostBaseUrl ;
40- } else {
41- return new CompositePartitionKey (
42- targetHostBaseUrl ,
43- virtualHost ,
44- null ,
45- 0 ,
46- null );
47- }
48- } else {
41+ if (proxyServer != null ) {
4942 return new CompositePartitionKey (
5043 targetHostBaseUrl ,
5144 virtualHost ,
@@ -55,6 +48,43 @@ public Object getPartitionKey(Uri uri, @Nullable String virtualHost, @Nullable P
5548 proxyServer .getPort (),
5649 proxyServer .getProxyType ());
5750 }
51+
52+ return new CompositePartitionKey (
53+ targetHostBaseUrl ,
54+ virtualHost ,
55+ null ,
56+ 0 ,
57+ null );
58+ }
59+ }
60+
61+ class PartitionKey {
62+ private final String scheme ;
63+ private final String host ;
64+ private final int port ;
65+
66+ PartitionKey (String scheme , String host , int port ) {
67+ this .scheme = scheme ;
68+ this .host = host ;
69+ this .port = port ;
70+ }
71+
72+ @ Override
73+ public boolean equals (Object o ) {
74+ if (o == null || getClass () != o .getClass ()) {
75+ return false ;
76+ }
77+
78+ PartitionKey that = (PartitionKey ) o ;
79+ return port == that .port && Objects .equals (scheme , that .scheme ) && Objects .equals (host , that .host );
80+ }
81+
82+ @ Override
83+ public int hashCode () {
84+ int result = Objects .hashCode (scheme );
85+ result = 31 * result + Objects .hashCode (host );
86+ result = 31 * result + port ;
87+ return result ;
5888 }
5989 }
6090
0 commit comments