You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "gMan1990 (GitHub)" <gi...@apache.org> on 2018/11/27 10:16:38 UTC

[GitHub] [incubator-dubbo] gMan1990 opened issue #2837: InjvmProtocol isInjvmRefer 方法是不是有bug?

https://github.com/apache/incubator-dubbo/blob/46b3458564cd0387d50f26f566556917cb74b999/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/InjvmProtocol.java#L99
这一行 isJvmRefer = false?true

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

[GitHub] [incubator-dubbo] gMan1990 closed issue #2837: InjvmProtocol isInjvmRefer 方法是不是有bug?

Posted by "gMan1990 (GitHub)" <gi...@apache.org>.
[ issue closed by gMan1990 ]

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


[GitHub] [incubator-dubbo] code4wt commented on issue #2837: InjvmProtocol isInjvmRefer 方法是不是有bug?

Posted by "code4wt (GitHub)" <gi...@apache.org>.
不算bug,只是逻辑上让人有点奇怪。当协议头为 injvm 时,Protocol 自适应拓展类会自动根据协议头加载指定的 Protocol 实现类。比如协议头为 injvm,就去加载 InjvmProtocol。自适应拓展类代码如下:

```java
public class Protocol$Adaptive implements com.alibaba.dubbo.rpc.Protocol {

    // 省略一部分代码

    public com.alibaba.dubbo.rpc.Invoker refer(java.lang.Class arg0, com.alibaba.dubbo.common.URL arg1)
        throws com.alibaba.dubbo.rpc.RpcException {
        if (arg1 == null) {
            throw new IllegalArgumentException("url == null");
        }
        com.alibaba.dubbo.common.URL url = arg1;
        // 获取协议头,默认为 dubbo
        String extName = (url.getProtocol() == null ? "dubbo" : url.getProtocol());
        if (extName == null) {
            throw new IllegalStateException(
                "Fail to get extension(com.alibaba.dubbo.rpc.Protocol) name from url(" + url.toString()
                    + ") use keys([protocol])");
        }

        // 通过 SPI 加载指定的 Protocol,比如 extName = injvm 时,就去加载 InjvmProtocol
        com.alibaba.dubbo.rpc.Protocol extension = (com.alibaba.dubbo.rpc.Protocol) ExtensionLoader
            .getExtensionLoader(com.alibaba.dubbo.rpc.Protocol.class).getExtension(extName);
        return extension.refer(arg0, arg1);
    }
}
```

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

[GitHub] [incubator-dubbo] gMan1990 commented on issue #2837: InjvmProtocol isInjvmRefer 方法是不是有bug?

Posted by "gMan1990 (GitHub)" <gi...@apache.org>.
soga 。。了解了

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