@@ -192,16 +192,14 @@ public void close() {
192192 public static class Builder {
193193 private final ManagedChannel channel ;
194194 private final boolean shutdownChannelOnClose ;
195+ private final boolean checkCompatibility ;
195196 @ Nullable private CallCredentials callCredentials ;
196197 @ Nullable private Duration timeout ;
197198
198199 Builder (ManagedChannel channel , boolean shutdownChannelOnClose , boolean checkCompatibility ) {
199200 this .channel = channel ;
200201 this .shutdownChannelOnClose = shutdownChannelOnClose ;
201- String clientVersion = Builder .class .getPackage ().getImplementationVersion ();
202- if (checkCompatibility ) {
203- checkVersionsCompatibility (clientVersion );
204- }
202+ this .checkCompatibility = checkCompatibility ;
205203 }
206204
207205 Builder (String host , int port , boolean useTransportLayerSecurity , boolean checkCompatibility ) {
@@ -210,9 +208,7 @@ public static class Builder {
210208 String userAgent = "java-client/" + clientVersion + " java/" + javaVersion ;
211209 this .channel = createChannel (host , port , useTransportLayerSecurity , userAgent );
212210 this .shutdownChannelOnClose = true ;
213- if (checkCompatibility ) {
214- checkVersionsCompatibility (clientVersion );
215- }
211+ this .checkCompatibility = checkCompatibility ;
216212 }
217213
218214 /**
@@ -255,6 +251,10 @@ public Builder withCallCredentials(@Nullable CallCredentials callCredentials) {
255251 * @return a new instance of {@link QdrantGrpcClient}
256252 */
257253 public QdrantGrpcClient build () {
254+ if (checkCompatibility ) {
255+ String clientVersion = Builder .class .getPackage ().getImplementationVersion ();
256+ checkVersionsCompatibility (clientVersion );
257+ }
258258 return new QdrantGrpcClient (channel , shutdownChannelOnClose , callCredentials , timeout );
259259 }
260260
@@ -277,6 +277,7 @@ private void checkVersionsCompatibility(String clientVersion) {
277277 try {
278278 String serverVersion =
279279 QdrantGrpc .newBlockingStub (this .channel )
280+ .withCallCredentials (this .callCredentials )
280281 .healthCheck (QdrantOuterClass .HealthCheckRequest .getDefaultInstance ())
281282 .getVersion ();
282283 if (!VersionsCompatibilityChecker .isCompatible (clientVersion , serverVersion )) {
0 commit comments