gabriel-farache commented on code in PR #4094:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4094#discussion_r2585947949


##########
quarkus/addons/token-exchange/runtime/src/main/java/org/kie/kogito/addons/quarkus/token/exchange/cache/TokenEvictionHandler.java:
##########
@@ -96,28 +116,41 @@ private void onTokenExpired(String cacheKey, CachedTokens 
tokens, RemovalCause c
 
     /**
      * Refreshes tokens using a cached refresh token and updates the cache.
-     * 
+     * The process instance context is set based on the cache key.
+     *
      * @param cacheKey The cache key for the tokens being refreshed
      * @param refreshToken The refresh token to use for getting new tokens
      */
     private void refreshWithCachedToken(String cacheKey, String refreshToken) {
+        // Extract process instance ID from cache key for context propagation
+        String processInstanceId = 
CacheUtils.extractProcessInstanceIdFromCacheKey(cacheKey);
+
         tokenRefreshExecutor.submit(() -> {
             try {
+                ProcessInstanceContext.setProcessInstanceId(processInstanceId);

Review Comment:
   Here we are doing it again as it's done in a separate Thread so it's safer 
to set it explicitly to avoid race issue, what do you think?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to