apache/dubbo

com.alibaba cluster、Directory兼容失败

Open

#6,026 创建于 2020年4月15日

在 GitHub 查看
 (4 评论) (0 反应) (0 负责人)Java (26,453 fork)batch import
help wanted

仓库指标

Star
 (41,524 star)
PR 合并指标
 (平均合并 7天 14小时) (30 天内合并 20 个 PR)

描述

  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.4.1
  • Operating System version: mac
  • Java version: 8

Steps to reproduce this issue

1、Cluster

@Deprecated
public interface Cluster extends org.apache.dubbo.rpc.cluster.Cluster {

    <T> com.alibaba.dubbo.rpc.Invoker<T> join(com.alibaba.dubbo.rpc.cluster.Directory<T> directory) throws
            com.alibaba.dubbo.rpc.RpcException;

    @Override
    default <T> Invoker<T> join(Directory<T> directory) throws RpcException {
        return null;
    }
}

join为什么返回NULL

2、Directory

public interface Directory<T> extends org.apache.dubbo.rpc.cluster.Directory<T> {

    @Override
    URL getUrl();

    List<com.alibaba.dubbo.rpc.Invoker<T>> list(com.alibaba.dubbo.rpc.Invocation invocation) throws com.alibaba.dubbo.rpc.RpcException;

    @Override
    default List<Invoker<T>> list(Invocation invocation) throws RpcException {
        List<com.alibaba.dubbo.rpc.Invoker<T>> res = this.list(new com.alibaba.dubbo.rpc.Invocation.CompatibleInvocation(invocation));
        return res.stream().map(i -> i.getOriginal()).collect(Collectors.toList());
    }
}

缺少兼容Directory,例如CompatibleDirectory

我们有老项目实现了Cluster,如果改新的包,很多项目都要动,量很大,所以需要兼容老的。

贡献者指南