Skip to content

Commit 2a6fb7c

Browse files
committed
fix: fallback to any known node when control node not found by endpoint
When the control connection endpoint doesn't match any node in metadata (e.g. with PrivateLink or proxy setups), fall back to the first available node instead of immediately throwing an exception.
1 parent e30a07d commit 2a6fb7c

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

core/src/main/java/com/datastax/oss/driver/internal/core/metadata/schema/queries/DefaultSchemaQueriesFactory.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ public SchemaQueries newInstance() {
5151
.getMetadataManager()
5252
.getMetadata()
5353
.findNode(channel.getEndPoint())
54-
.orElseThrow(
54+
.orElseGet(
5555
() ->
56-
new IllegalStateException(
57-
"Could not find control node metadata "
58-
+ channel.getEndPoint()
59-
+ ", aborting schema refresh"));
56+
context.getMetadataManager().getMetadata().getNodes().values().stream()
57+
.findFirst()
58+
.orElseThrow(
59+
() ->
60+
new IllegalStateException(
61+
"Could not find control node metadata "
62+
+ channel.getEndPoint()
63+
+ ", aborting schema refresh")));
6064
return newInstance(node, channel);
6165
}
6266

0 commit comments

Comments
 (0)