Skip to content

Commit 73db694

Browse files
committed
MLE-25959 Quieted down PDC logging
Info-level was too verbose for token generation. Also fixed a little bug in an error message built for an exception.
1 parent 8c2f2eb commit 73db694

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group=com.marklogic
2-
version=8.0-SNAPSHOT
2+
version=8.1-SNAPSHOT
33
publishUrl=file:../marklogic-java/releases
44

55
okhttpVersion=5.2.0

marklogic-client-api/src/main/java/com/marklogic/client/impl/okhttp/ProgressDataCloudAuthenticationConfigurer.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ProgressDataCloudAuthenticationConfigurer implements AuthenticationConfigu
2424
@Override
2525
public void configureAuthentication(OkHttpClient.Builder clientBuilder, DatabaseClientFactory.ProgressDataCloudAuthContext securityContext) {
2626
final String apiKey = securityContext.getApiKey();
27-
if (apiKey == null || apiKey.trim().length() < 1) {
27+
if (apiKey == null || apiKey.trim().isEmpty()) {
2828
throw new IllegalArgumentException("No API key provided");
2929
}
3030
TokenGenerator tokenGenerator = new DefaultTokenGenerator(this.host, securityContext);
@@ -56,8 +56,8 @@ public DefaultTokenGenerator(String host, DatabaseClientFactory.ProgressDataClou
5656
public String generateToken() {
5757
final Response tokenResponse = callTokenEndpoint();
5858
String token = getAccessTokenFromResponse(tokenResponse);
59-
if (logger.isInfoEnabled()) {
60-
logger.info("Successfully obtained authentication token");
59+
if (logger.isDebugEnabled()) {
60+
logger.debug("Successfully obtained authentication token");
6161
}
6262
return token;
6363
}
@@ -70,8 +70,8 @@ private Response callTokenEndpoint() {
7070
OkHttpUtil.configureSocketFactory(clientBuilder, securityContext.getSSLContext(), securityContext.getTrustManager());
7171
OkHttpUtil.configureHostnameVerifier(clientBuilder, securityContext.getSSLHostnameVerifier());
7272

73-
if (logger.isInfoEnabled()) {
74-
logger.info("Calling token endpoint at: " + tokenUrl);
73+
if (logger.isDebugEnabled()) {
74+
logger.debug("Calling token endpoint at: {}", tokenUrl);
7575
}
7676

7777
final Call call = clientBuilder.build().newCall(
@@ -85,7 +85,7 @@ private Response callTokenEndpoint() {
8585
return call.execute();
8686
} catch (IOException e) {
8787
throw new ProgressDataCloudException(String.format("Unable to call token endpoint at %s; cause: %s",
88-
tokenUrl, e.getMessage(), e));
88+
tokenUrl, e.getMessage()), e);
8989
}
9090
}
9191

@@ -97,7 +97,8 @@ protected HttpUrl buildTokenUrl() {
9797
.host(host)
9898
.port(443)
9999
.build()
100-
.resolve(securityContext.getTokenEndpoint()).newBuilder();
100+
.resolve(securityContext.getTokenEndpoint())
101+
.newBuilder();
101102

102103
Integer duration = securityContext.getTokenDuration();
103104
return duration != null ?
@@ -146,7 +147,7 @@ public TokenAuthenticationInterceptor(TokenGenerator tokenGenerator) {
146147
@Override
147148
public Response intercept(Chain chain) throws IOException {
148149
Request.Builder builder = chain.request().newBuilder();
149-
addTokenToRequest(builder);
150+
builder = addTokenToRequest(builder);
150151
Response response = chain.proceed(builder.build());
151152
if (response.code() == 401) {
152153
logger.info("Received 401; will generate new token if necessary and retry request");
@@ -155,7 +156,7 @@ public Response intercept(Chain chain) throws IOException {
155156
generateNewTokenIfNecessary(currentToken);
156157

157158
builder = chain.request().newBuilder();
158-
addTokenToRequest(builder);
159+
builder = addTokenToRequest(builder);
159160
response = chain.proceed(builder.build());
160161
}
161162
return response;

0 commit comments

Comments
 (0)