Skip to content

Commit 9526f35

Browse files
committed
Improve comments/documentation
1 parent b0a41a8 commit 9526f35

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/tokenprovider/AbstractUaaTokenProvider.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -335,16 +335,18 @@ private Mono<String> token(final ConnectionContext connectionContext) {
335335
return existingRequest;
336336
}
337337

338-
// Create new token request with proper synchronization
339338
final Mono<String> baseTokenRequest = createTokenRequest(connectionContext)
340-
.publishOn(connectionContext.getTokenScheduler()) // Ensure execution on single thread
341-
.doOnSubscribe(s -> LOGGER.debug("Starting new token request"))
342-
.doOnSuccess(token -> LOGGER.debug("Token request completed successfully"))
343-
.doOnError(error -> LOGGER.debug("Token request failed", error))
339+
/*
340+
* Ensure execution on single thread.
341+
* This prevents sending requests to the UAA server with expired refresh tokens.
342+
*/
343+
.publishOn(connectionContext.getTokenScheduler())
344+
.doOnSubscribe(s -> LOGGER.debug("Starting new UAA JWT token request"))
345+
.doOnSuccess(token -> LOGGER.debug("UAA JWT token request completed successfully"))
346+
.doOnError(error -> LOGGER.debug("UAA JWT token request failed", error))
344347
.doFinally(signal -> {
345348
// Clear the active request when done (success or error)
346349
this.activeTokenRequests.remove(connectionContext);
347-
LOGGER.debug("Cleared active token request for connection context");
348350
});
349351

350352
// Apply cache duration from connection context
@@ -356,8 +358,8 @@ private Mono<String> token(final ConnectionContext connectionContext) {
356358
// Store the active request atomically
357359
final Mono<String> actualRequest = this.activeTokenRequests.putIfAbsent(connectionContext, newTokenRequest);
358360
if (actualRequest != null) {
359-
// Another thread beat us to it, use their request
360-
LOGGER.debug("Another thread created token request first, using theirs");
361+
// Another thread beat us to it, use their request. This prevents "wasteful" requests.
362+
LOGGER.debug("Another thread created token request first, using theirs instead");
361363
return actualRequest;
362364
}
363365

0 commit comments

Comments
 (0)