From 645c9c9ec40291b390cb03ab735971cb7815cd87 Mon Sep 17 00:00:00 2001 From: tellet-q Date: Thu, 11 Dec 2025 16:24:36 +0100 Subject: [PATCH] Move version compatibility check until after api key obtained --- .../java/io/qdrant/client/QdrantGrpcClient.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/qdrant/client/QdrantGrpcClient.java b/src/main/java/io/qdrant/client/QdrantGrpcClient.java index e0ecf758..3e0364c6 100644 --- a/src/main/java/io/qdrant/client/QdrantGrpcClient.java +++ b/src/main/java/io/qdrant/client/QdrantGrpcClient.java @@ -192,16 +192,14 @@ public void close() { public static class Builder { private final ManagedChannel channel; private final boolean shutdownChannelOnClose; + private final boolean checkCompatibility; @Nullable private CallCredentials callCredentials; @Nullable private Duration timeout; Builder(ManagedChannel channel, boolean shutdownChannelOnClose, boolean checkCompatibility) { this.channel = channel; this.shutdownChannelOnClose = shutdownChannelOnClose; - String clientVersion = Builder.class.getPackage().getImplementationVersion(); - if (checkCompatibility) { - checkVersionsCompatibility(clientVersion); - } + this.checkCompatibility = checkCompatibility; } Builder(String host, int port, boolean useTransportLayerSecurity, boolean checkCompatibility) { @@ -210,9 +208,7 @@ public static class Builder { String userAgent = "java-client/" + clientVersion + " java/" + javaVersion; this.channel = createChannel(host, port, useTransportLayerSecurity, userAgent); this.shutdownChannelOnClose = true; - if (checkCompatibility) { - checkVersionsCompatibility(clientVersion); - } + this.checkCompatibility = checkCompatibility; } /** @@ -255,6 +251,10 @@ public Builder withCallCredentials(@Nullable CallCredentials callCredentials) { * @return a new instance of {@link QdrantGrpcClient} */ public QdrantGrpcClient build() { + if (checkCompatibility) { + String clientVersion = Builder.class.getPackage().getImplementationVersion(); + checkVersionsCompatibility(clientVersion); + } return new QdrantGrpcClient(channel, shutdownChannelOnClose, callCredentials, timeout); } @@ -277,6 +277,7 @@ private void checkVersionsCompatibility(String clientVersion) { try { String serverVersion = QdrantGrpc.newBlockingStub(this.channel) + .withCallCredentials(this.callCredentials) .healthCheck(QdrantOuterClass.HealthCheckRequest.getDefaultInstance()) .getVersion(); if (!VersionsCompatibilityChecker.isCompatible(clientVersion, serverVersion)) {