apache / apache/dubbo

compatible problem with FutureAdapter

Open
#6,126 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

### Environment

* Dubbo version: 2.7.6
* Operating System version: xxx
* Java version: xxx

### Steps to reproduce this issue

in dubbo, we can write async code like below:
``` java
import com.alibaba.dubbo.remoting.exchange.ResponseCallback;
import com.alibaba.dubbo.remoting.exchange.ResponseFuture;
import com.alibaba.dubbo.rpc.RpcContext;
import com.alibaba.dubbo.rpc.protocol.dubbo.FutureAdapter;
import com.alibaba.dubbo.rpc.Result;

interface TestService {
String test();
}

testService.test();
ResponseFuture future = ((FutureAdapter) RpcContext.getContext().getFuture()).getFuture();
future.setCallback(new ResponseCallback(){
public void done(Object response){
assert response instanceof Result;// in 2.6.x
assert response instanceof String;// in 2.7.x
}

public void caught(Throwable exception){
}
});
```
however, response is an object of Result in 2.6.x but String in 2.7.x.
when project update to 2.7.x, we may find runtime error.

如果我们用上面的代码段做异步调用,在2.7.x里面,response会是一个String,但是在2.6.x,response会是一个com.alibaba.dubbo.rpc.Result。
如果从2.6升级到2.7,必须要查找所有进行调用的地方并修改代码,这不太合理。

Contributor guide

Open the contributing guide

Research direction

Start at FutureAdapter and the ResponseFuture callback path shown in the reproduction, comparing how 2.6.x and 2.7.x produce the callback response. Determine the intended compatibility contract for Result versus String, then add a regression test for the async call; done means the upgrade behavior is consistent and documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.