@@ -42,7 +42,7 @@ public final class ClientRouteProxy {
4242 private static final Pattern VALID_HOSTNAME_OR_IP = Pattern .compile ("^[a-zA-Z0-9._:\\ [\\ ]-]+$" );
4343
4444 private final String connectionId ;
45- private final String connectionAddr ;
45+ private final String connectionAddrOverride ;
4646
4747 /**
4848 * Creates a new endpoint with the given connection ID and no connection address.
@@ -57,35 +57,35 @@ public ClientRouteProxy(@NonNull String connectionId) {
5757 * Creates a new endpoint with the given connection ID and connection address.
5858 *
5959 * @param connectionId the connection ID (must not be null).
60- * @param connectionAddr the DNS name or IP address used to override the {@code address} column
60+ * @param connectionAddrOverride the DNS name or IP address used to override the {@code address} column
6161 * from the {@code system.client_routes} table for the matching {@code connection_id} (may be
6262 * null). Must be a plain hostname or IP address without a port (e.g. {@code
6363 * "my-cluster.example.com"} or {@code "10.0.1.5"}).
6464 */
65- public ClientRouteProxy (@ NonNull String connectionId , @ Nullable String connectionAddr ) {
65+ public ClientRouteProxy (@ NonNull String connectionId , @ Nullable String connectionAddrOverride ) {
6666 this .connectionId = Objects .requireNonNull (connectionId , "connectionId must not be null" );
6767 if (connectionId .trim ().isEmpty ()) {
6868 throw new IllegalArgumentException ("connectionId must not be empty" );
6969 }
70- if (connectionAddr != null ) {
71- if (connectionAddr .trim ().isEmpty ()) {
70+ if (connectionAddrOverride != null ) {
71+ if (connectionAddrOverride .trim ().isEmpty ()) {
7272 throw new IllegalArgumentException (
73- "connectionAddr must not be empty or blank when non-null" );
73+ "connectionAddrOverride must not be empty or blank when non-null" );
7474 }
75- if (containsPort (connectionAddr )) {
75+ if (containsPort (connectionAddrOverride )) {
7676 throw new IllegalArgumentException (
77- "connectionAddr must be a plain hostname or IP address without a port, got: "
78- + connectionAddr );
77+ "connectionAddrOverride must be a plain hostname or IP address without a port, got: "
78+ + connectionAddrOverride );
7979 }
80- if (!VALID_HOSTNAME_OR_IP .matcher (connectionAddr ).matches ()) {
80+ if (!VALID_HOSTNAME_OR_IP .matcher (connectionAddrOverride ).matches ()) {
8181 throw new IllegalArgumentException (
82- "connectionAddr contains invalid characters "
82+ "connectionAddrOverride contains invalid characters "
8383 + "(expected hostname or IP address with only alphanumeric characters, "
8484 + "dots, hyphens, underscores, colons, or brackets): "
85- + connectionAddr );
85+ + connectionAddrOverride );
8686 }
8787 }
88- this .connectionAddr = connectionAddr ;
88+ this .connectionAddrOverride = connectionAddrOverride ;
8989 }
9090
9191 /**
@@ -124,10 +124,24 @@ public String getConnectionId() {
124124 * <p>This is a plain hostname or IP address (e.g. {@code "my-cluster.example.com"} or {@code
125125 * "10.0.1.5"}). When provided, the {@code address} column from the {@code system.client_routes}
126126 * table is overridden with this value for the matching {@code connection_id}.
127+ * @deprecated use {@link ClientRouteProxy#getConnectionAddrOverride()} instead
127128 */
128129 @ Nullable
130+ @ Deprecated
129131 public String getConnectionAddr () {
130- return connectionAddr ;
132+ return connectionAddrOverride ;
133+ }
134+
135+ /**
136+ * Returns the connection address override for this endpoint, or null if not specified.
137+ *
138+ * <p>This is a plain hostname or IP address (e.g. {@code "my-cluster.example.com"} or {@code
139+ * "10.0.1.5"}). When provided, the {@code address} column from the {@code system.client_routes}
140+ * table is overridden with this value for the matching {@code connection_id}.
141+ */
142+ @ Nullable
143+ public String getConnectionAddrOverride () {
144+ return connectionAddrOverride ;
131145 }
132146
133147 @ Override
@@ -140,12 +154,12 @@ public boolean equals(Object o) {
140154 }
141155 ClientRouteProxy that = (ClientRouteProxy ) o ;
142156 return connectionId .equals (that .connectionId )
143- && Objects .equals (connectionAddr , that .connectionAddr );
157+ && Objects .equals (connectionAddrOverride , that .connectionAddrOverride );
144158 }
145159
146160 @ Override
147161 public int hashCode () {
148- return Objects .hash (connectionId , connectionAddr );
162+ return Objects .hash (connectionId , connectionAddrOverride );
149163 }
150164
151165 @ Override
@@ -154,7 +168,7 @@ public String toString() {
154168 + "connectionId='"
155169 + connectionId
156170 + "'"
157- + (connectionAddr != null ? ", connectionAddr ='" + connectionAddr + "'" : "" )
171+ + (connectionAddrOverride != null ? ", connectionAddrOverride ='" + connectionAddrOverride + "'" : "" )
158172 + "}" ;
159173 }
160174}
0 commit comments