Skip to content

Commit 262792a

Browse files
committed
fix: forward request context and session in fault tolerance request filter
1 parent 88175fa commit 262792a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

gateway/src/main/java/com/mx/path/gateway/connect/filter/FaultTolerantRequestFilter.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.mx.path.core.common.http.HttpStatus;
88
import com.mx.path.core.common.process.FaultTolerantExecutor;
99
import com.mx.path.core.context.RequestContext;
10+
import com.mx.path.core.context.Session;
1011
import com.mx.path.core.context.facility.Facilities;
1112
import com.mx.path.gateway.context.GatewayRequestContext;
1213

@@ -21,8 +22,21 @@ public final void execute(Request request, Response response) {
2122
FaultTolerantExecutor faultTolerantExecutor = Facilities.getFaultTolerantExecutor(RequestContext.current().getClientId());
2223
if (faultTolerantExecutor != null) {
2324
try {
25+
RequestContext currentRequestContext = RequestContext.current();
26+
Session currentSession = Session.current();
27+
2428
String scope = request.getFaultTolerantScope() != null ? request.getFaultTolerantScope() : buildScope();
2529
faultTolerantExecutor.submit(scope, scopeConfigurations -> {
30+
31+
// Forward context objects to current thread.
32+
if (currentRequestContext != null) {
33+
currentRequestContext.register();
34+
}
35+
36+
if (currentSession != null) {
37+
Session.setCurrent(currentSession);
38+
}
39+
2640
// If a request timeout was explicitly provided (should be rare) we respect it. Otherwise, we use the timeout
2741
// that the FaultTolerantExecutor is using for this request.
2842
if (request.getRequestTimeOut() == null) {

0 commit comments

Comments
 (0)