fix GenericFilter get generic value (#10456)

This commit is contained in:
liufeiyu1002 2022-08-14 21:12:00 +08:00 committed by GitHub
parent 29e4e4235b
commit e528bca7e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -97,7 +97,7 @@ public class GenericFilter implements Filter, Filter.Listener, ScopeModelAware {
String generic = inv.getAttachment(GENERIC_KEY);
if (StringUtils.isBlank(generic)) {
generic = RpcContext.getClientAttachment().getAttachment(GENERIC_KEY);
generic = getGenericValueFromRpcContext();
}
if (StringUtils.isEmpty(generic)
@ -205,6 +205,14 @@ public class GenericFilter implements Filter, Filter.Listener, ScopeModelAware {
}).toArray();
}
private String getGenericValueFromRpcContext(){
String generic = RpcContext.getServerAttachment().getAttachment(GENERIC_KEY);
if (StringUtils.isBlank(generic)){
generic = RpcContext.getClientAttachment().getAttachment(GENERIC_KEY);
}
return generic;
}
@Override
public void onResponse(Result appResponse, Invoker<?> invoker, Invocation inv) {
if ((inv.getMethodName().equals($INVOKE) || inv.getMethodName().equals($INVOKE_ASYNC))
@ -214,7 +222,7 @@ public class GenericFilter implements Filter, Filter.Listener, ScopeModelAware {
String generic = inv.getAttachment(GENERIC_KEY);
if (StringUtils.isBlank(generic)) {
generic = RpcContext.getClientAttachment().getAttachment(GENERIC_KEY);
generic = getGenericValueFromRpcContext();
}
if (appResponse.hasException()) {