@@ -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
61- * from the {@code system.client_routes} table for the matching {@code connection_id} (may be
62- * null). Must be a plain hostname or IP address without a port (e.g. {@code
60+ * @param connectionAddrOverride the DNS name or IP address used to override the {@code address}
61+ * column from the {@code system.client_routes} table for the matching {@code connection_id}
62+ * (may be 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,25 @@ 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+ *
128+ * @deprecated use {@link ClientRouteProxy#getConnectionAddrOverride()} instead
127129 */
128130 @ Nullable
131+ @ Deprecated
129132 public String getConnectionAddr () {
130- return connectionAddr ;
133+ return connectionAddrOverride ;
134+ }
135+
136+ /**
137+ * Returns the connection address override for this endpoint, or null if not specified.
138+ *
139+ * <p>This is a plain hostname or IP address (e.g. {@code "my-cluster.example.com"} or {@code
140+ * "10.0.1.5"}). When provided, the {@code address} column from the {@code system.client_routes}
141+ * table is overridden with this value for the matching {@code connection_id}.
142+ */
143+ @ Nullable
144+ public String getConnectionAddrOverride () {
145+ return connectionAddrOverride ;
131146 }
132147
133148 @ Override
@@ -140,12 +155,12 @@ public boolean equals(Object o) {
140155 }
141156 ClientRouteProxy that = (ClientRouteProxy ) o ;
142157 return connectionId .equals (that .connectionId )
143- && Objects .equals (connectionAddr , that .connectionAddr );
158+ && Objects .equals (connectionAddrOverride , that .connectionAddrOverride );
144159 }
145160
146161 @ Override
147162 public int hashCode () {
148- return Objects .hash (connectionId , connectionAddr );
163+ return Objects .hash (connectionId , connectionAddrOverride );
149164 }
150165
151166 @ Override
@@ -154,7 +169,9 @@ public String toString() {
154169 + "connectionId='"
155170 + connectionId
156171 + "'"
157- + (connectionAddr != null ? ", connectionAddr='" + connectionAddr + "'" : "" )
172+ + (connectionAddrOverride != null
173+ ? ", connectionAddrOverride='" + connectionAddrOverride + "'"
174+ : "" )
158175 + "}" ;
159176 }
160177}
0 commit comments