@@ -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