77import com .mx .path .core .common .http .HttpStatus ;
88import com .mx .path .core .common .process .FaultTolerantExecutor ;
99import com .mx .path .core .context .RequestContext ;
10+ import com .mx .path .core .context .ResponseContext ;
11+ import com .mx .path .core .context .Session ;
1012import com .mx .path .core .context .facility .Facilities ;
1113import com .mx .path .gateway .context .GatewayRequestContext ;
1214
@@ -21,8 +23,26 @@ public final void execute(Request request, Response response) {
2123 FaultTolerantExecutor faultTolerantExecutor = Facilities .getFaultTolerantExecutor (RequestContext .current ().getClientId ());
2224 if (faultTolerantExecutor != null ) {
2325 try {
26+ RequestContext currentRequestContext = RequestContext .current ();
27+ ResponseContext currentResponseContext = ResponseContext .current ();
28+ Session currentSession = Session .current ();
29+
2430 String scope = request .getFaultTolerantScope () != null ? request .getFaultTolerantScope () : buildScope ();
2531 faultTolerantExecutor .submit (scope , scopeConfigurations -> {
32+
33+ // Forward context objects to current thread.
34+ if (currentRequestContext != null ) {
35+ currentRequestContext .register ();
36+ }
37+
38+ if (currentResponseContext != null ) {
39+ currentResponseContext .register ();
40+ }
41+
42+ if (currentSession != null ) {
43+ Session .setCurrent (currentSession );
44+ }
45+
2646 // If a request timeout was explicitly provided (should be rare) we respect it. Otherwise, we use the timeout
2747 // that the FaultTolerantExecutor is using for this request.
2848 if (request .getRequestTimeOut () == null ) {
0 commit comments