[apache/dubbo]Stub Proxy 配置 Bug

2024-05-30 483 views
9

当定义BarService并定义BarServiceStub时,配置如下其实是不会生效的

<dubbo:service interface="com.foo.BarService" stub="true" />
源码跟踪

com.alibaba.dubbo.config.ServiceConfig#doExport()

if(local !=null){   // 文档中并没有与local相关的参数解释
    if(local=="true"){
        local=interfaceName+"Local";
    }
    Class<?> localClass;
    try {
        localClass = ClassHelper.forNameWithThreadContextClassLoader(local);
    } catch (ClassNotFoundException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
    if(!interfaceClass.isAssignableFrom(localClass)){
        throw new IllegalStateException("The local implemention class " + localClass.getName() + " not implement interface " + interfaceName);
    }
}

if(stub !=null){
    if(stub=="true"){ // 最坑爹的错误是这里,文档说stub="true"默认interfaceName+Local(实际是+Stub,参见下一个注释),可是这是String对象啊,如果外面stub赋值不是stub="true"的话,设置了true也不会进来,应该修改为stub.equals("true"),上面Local也一样
        stub=interfaceName+"Stub";  // 这里文档中的解释有误,文档中写的是+Local,即与上面的Local一致
    }
    Class<?> stubClass;
    try {
        stubClass = ClassHelper.forNameWithThreadContextClassLoader(stub);
    } catch (ClassNotFoundException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
    if(!interfaceClass.isAssignableFrom(stubClass)){
        throw new IllegalStateException("The stub implemention class " + stubClass.getName() + " not implement interface " + interfaceName);
    }
}

回答

4

我也发现了这个问题, 这里的字符串应该是 "true".equals() 的, 现在只能使用 Stub 类名来代替

3

有更新了?僵尸项目要复活了么?

1

@xwarrior 准备适应这个时代,把他做的更轻更易用。

4

@teaey 现在用这个框架会不会已经过时了? HSF有源代码吗?

8

@liangz168 你说过时是指架构吗?

7

@yinjun622 我是询问一下,毕竟3年没有更新过了

8

@teaey 期待新版本的更新! 加油!

1

期待

1

期待。dubbo怎么过时?请问怎么加入dubbo源码贡献者?

3

@slowlizard 关键不是怎么成为dubbo的代码贡献者,而是你有没有好的feture。

2

@teaey 能支持etcd和consul作为注册中心吗?

0

@rexren 自己根据注册中心接口实现一套,可是很容易的