cwt9562 commented on issue #10717:
URL: https://github.com/apache/dubbo/issues/10717#issuecomment-1275522990
我找到并规避了这个问题,但我觉得,它应该是可以被解决了
provider错乱的原因是,我自定义了一个comsumer的filter
这个filter主要任务是,将当前登录用户(登录由shiro管理)中的userid,传递给privider侧
```
@Activate(group = CommonConstants.CONSUMER)
@Slf4j
public class CustomContextFilter implements Filter {
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws
RpcException {
setCurrentUserId();
setCurrentRemoteIp();
return invoker.invoke(invocation);
}
private void setCurrentUserId() {
...
RpcContext.getClientAttachment().setAttachment(Constants.CURRENT_USER_ID,
currentUserId);
...
}
private void setCurrentRemoteIp() {
...
RpcContext.getClientAttachment().setAttachment(Constants.CURRENT_REMOTE_IP,
currentRemoteIp);
...
}
}
```
但是,我在setCurrentUserId()方法里,犯了一个错误,
层层调用之下,居然发起了另一个dubbo rpc请求,去调用了UserProvider的getByUsername()方法
在UserProvider的getByUsername()被调用完毕后,回到CustomContextFilter的invoke()方法的return
invoker.invoke(invocation);后,原本的调用就错乱了
不管本次请求原本是调用的AbcProvider的abc()方法,还是XyzProvider的xyz()方法
统统变成了UserProvider的abc()方法和UserProvider的xyz()方法
--
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]