Skip to content

Commit 35b6df1

Browse files
committed
only use basic or digest authentication, not both at the same time--this prevents losing non-retryable payloads on Java 1.7
1 parent bc9b6fd commit 35b6df1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/main/java/com/marklogic/client/impl/OkHttpServices.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,15 @@ private void connect(String host, int port, String database, String user, String
307307
final BasicAuthenticator basicAuthenticator = new BasicAuthenticator(credentials);
308308
final DigestAuthenticator digestAuthenticator = new DigestAuthenticator(credentials);
309309

310-
DispatchingAuthenticator authenticator = new DispatchingAuthenticator.Builder()
311-
.with("digest", digestAuthenticator)
312-
.with("basic", basicAuthenticator)
313-
.build();
310+
DispatchingAuthenticator.Builder authenticator = new DispatchingAuthenticator.Builder();
311+
if (authenType == Authentication.BASIC) {
312+
authenticator = authenticator.with("basic", basicAuthenticator);
313+
} else if (authenType == Authentication.DIGEST) {
314+
authenticator = authenticator.with("digest", digestAuthenticator);
315+
}
314316

315317
this.client = new OkHttpClient.Builder()
316-
.authenticator(new CachingAuthenticatorDecorator(authenticator, authCache))
318+
.authenticator(new CachingAuthenticatorDecorator(authenticator.build(), authCache))
317319
.addInterceptor(new AuthenticationCacheInterceptor(authCache))
318320
/*
319321
.addNetworkInterceptor(

0 commit comments

Comments
 (0)