You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "carryxyh (GitHub)" <gi...@apache.org> on 2019/03/25 09:23:39 UTC

[GitHub] [incubator-dubbo] carryxyh commented on issue #3185: [Dubbo-3169]Check future status before get(), return default value if not completed yet.

@chickenlj 
I found that the pr on this issue may cause an additional problem with `CacheFilter`:

```
String key = StringUtils.toArgumentString(invocation.getArguments());
Object value = cache.get(key);
if (value != null) {
    if (value instanceof ValueWrapper) {
        return new RpcResult(((ValueWrapper)value).get());
    } else {
        return new RpcResult(value);
    }
}
// In an asynchronous scenario, result.getValue() will return an empty RpcResult
Result result = invoker.invoke(invocation);
if (!result.hasException()) {
    // since the rpcResult#hasException will return false, this empty result will be cached.
    cache.put(key, new ValueWrapper(result.getValue()));
}
return result; 
```

In this scenario, CacheFilter will cache an empty `RpcResult`, which is incorrect.

[ Full content available at: https://github.com/apache/incubator-dubbo/pull/3185 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org