Skip to content

Commit 38cc4eb

Browse files
authored
[#4821] Fixed concurrent scenarios localContext empty problem (#4836)
1 parent 1ef5df8 commit 38cc4eb

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadbalanceHandler.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ public LoadbalanceHandler() {
8989

9090
private void preCheck() {
9191
// Old configurations check.Just print an error, because configurations may given in dynamic and fail on runtime.
92-
9392
String policyName = DynamicPropertyFactory.getInstance()
9493
.getStringProperty("servicecomb.loadbalance.NFLoadBalancerRuleClassName", null)
9594
.get();
@@ -115,8 +114,9 @@ public void handle(Invocation invocation, AsyncResponse asyncResp) throws Except
115114
response.handle(async);
116115
};
117116

118-
if (handleSuppliedEndpoint(invocation, asyncResp)) {
117+
if (handleSuppliedEndpoint(invocation)) {
119118
invocation.addLocalContext(RetryContext.RETRY_LOAD_BALANCE, false);
119+
invocation.next(asyncResp);
120120
return;
121121
}
122122
invocation.addLocalContext(RetryContext.RETRY_LOAD_BALANCE, true);
@@ -137,15 +137,13 @@ public void handle(Invocation invocation, AsyncResponse asyncResp) throws Except
137137

138138
// user's can invoke a service by supplying target Endpoint.
139139
// in this case, we do not using load balancer, and no stats of server calculated, no retrying.
140-
private boolean handleSuppliedEndpoint(Invocation invocation,
141-
AsyncResponse asyncResp) throws Exception {
140+
private boolean handleSuppliedEndpoint(Invocation invocation) throws Exception {
142141
if (invocation.getEndpoint() != null) {
143-
invocation.next(asyncResp);
144142
return true;
145143
}
146144

147145
if (supportDefinedEndpoint) {
148-
return defineEndpointAndHandle(invocation, asyncResp);
146+
return defineEndpointAndHandle(invocation);
149147
}
150148

151149
return false;
@@ -162,7 +160,7 @@ private Endpoint parseEndpoint(String endpointUri) throws Exception {
162160
return new Endpoint(transport, endpointUri);
163161
}
164162

165-
private boolean defineEndpointAndHandle(Invocation invocation, AsyncResponse asyncResp) throws Exception {
163+
private boolean defineEndpointAndHandle(Invocation invocation) throws Exception {
166164
Object endpoint = invocation.getLocalContext(SERVICECOMB_SERVER_ENDPOINT);
167165
if (endpoint == null) {
168166
return false;
@@ -173,7 +171,6 @@ private boolean defineEndpointAndHandle(Invocation invocation, AsyncResponse asy
173171
}
174172

175173
invocation.setEndpoint((Endpoint) endpoint);
176-
invocation.next(asyncResp);
177174
return true;
178175
}
179176

0 commit comments

Comments
 (0)