weibocom / motan

A cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.
Other
5.88k stars 1.78k forks source link

CommonProxyFactory这个类里面有bug #1065

Open traveltheworldd opened 2 months ago

traveltheworldd commented 2 months ago

@SpiMeta(name = "common") public class CommonProxyFactory implements ProxyFactory {

@Override
@SuppressWarnings("unchecked")
public <T> T getProxy(Class<T> clz, List<Cluster<T>> clusters) {
    return (T) new RefererCommonHandler(clusters.get(0).getUrl().getPath(), clusters);
}

@Override
@SuppressWarnings("unchecked")
public <T> T getProxy(Class<T> clz, URL refUrl, MeshClient meshClient) {
    return (T) new MeshClientRefererInvocationHandler(refUrl, meshClient);
}

}

return (T) new RefererCommonHandler(clusters.get(0).getUrl().getPath(), clusters);

这个地方强制转换是会报错的,是个bug,大家用的时候注意下,这个common的代理是行不通的

rayzhang0603 commented 2 months ago

CommonProxyFactory不是使用在动态代理场景的,是用来创建CommonClient或MeshClient,用在调用其他语言RPC或者MotanMesh的场景使用的。

这种场景下Java侧没有其他语言对应的service类,所以不能使用动态代理方式,需要使用client方式请求其他语言的RPC服务

CommonClient的使用方式可以参考Demo中的Motan2RpcClient

MeshClient的使用方式可以参考Demo中的DemoMeshClient