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


##########
jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcessInstance.java:
##########
@@ -225,9 +226,35 @@ protected void reconnect() {
         }
         
getProcessRuntime().getProcessInstanceManager().setLock(((MutableProcessInstances<T>)
 process.instances()).lock());
         processInstance.setMetaData(KOGITO_PROCESS_INSTANCE, this);
+
+        restoreProcessInstanceContext();
+
         processInstance.reconnect();
     }
 
+    private void restoreProcessInstanceContext() {
+        Map<String, List<String>> headers = processInstance.getHeaders();
+        if (headers != null && !headers.isEmpty()) {
+            Map<String, String> contextMap = 
convertHeadersToContextMap(headers);
+            if (!contextMap.isEmpty()) {
+                
org.kie.kogito.services.context.ProcessInstanceContext.setContextFromAsync(contextMap);

Review Comment:
   yes, and along an execution flow in the same thread, I think we can have 
this situation:
   
   ```
   method1() 
       put m1Key=1 in the MDC
   
       call method2() 
            put m2Key=2 in the MDC
   
            call method3()
                 do MDC.setContextMap(newMap)
                 the context in the Thread local was now set to newMap, m1Key 
and m2Key aren't in the newMap
            end 
     
            method2 continues, but has lost m2Key
   
         end
   
         method1 continues, but has lost m1Key
   end
   
   ```
      
   
   
   
   



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