[apache/dubbo]isConsumerSide 报 null 问题

2023-12-25 918 views
7
Environment
  • Dubbo version: 3.1.2
  • Operating System version: linux
  • Java version: 1.8
Steps to reproduce this issue

之前用的3.1.1提过一次了 让我升级3.1.2 升级之后还是有问题 https://github.com/apache/dubbo/issues/10704

回答

0

那现在应该怎么办 等着发布3.1.3嘛

2

3.1.3 本周会发布,此外的可以配置 scope=remote 使用远程调用避免

5

@AlbumenJ 这个问题任然存在 (3.1.3)

case 1 泛化调用

@Test
    public void testGenericService() {
        ReferenceConfig<GenericService> config = new ReferenceConfig<>();
        config.setInterface("org.apache.dubbo.samples.local.api.DemoService");
        config.setGeneric(Boolean.TRUE.toString());
        String result = (String)config.get().$invoke("sayHello", new String[]{"java.lang.String"}, new String[]{"world"});
    }

case 2

@Activate(group = {CommonConstants.PROVIDER, CommonConstants.CONSUMER})
public class DubboRequestFilter implements Filter {

    private final static Logger log = LoggerFactory.getLogger(DubboRequestFilter.class);

    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        RpcContext.getServiceContext().isConsumerSide();
        Result invoke = invoker.invoke(invocation);
        //NPE
        RpcContext.getServiceContext().isConsumerSide();
        return invoke;
    }
}

case 3

java.lang.NullPointerException: null
    at org.apache.dubbo.rpc.RpcServiceContext.isConsumerSide(RpcServiceContext.java:144)
    at org.apache.dubbo.rpc.RpcContext.isConsumerSide(RpcContext.java:275)
    at com....XxxDubboFilter.invoke(XxxDubboFilter.java:28)
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327)
    at com.alibaba.csp.sentinel.adapter.dubbo.DubboAppContextFilter.invoke(DubboAppContextFilter.java:43)
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:327)
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CallbackRegistrationInvoker.invoke(FilterChainBuilder.java:194)
    at org.apache.dubbo.rpc.proxy.InvocationUtil.invoke(InvocationUtil.java:56)
    at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:75)
    at org.apache.dubbo.metadata.MetadataServiceDubboProxy0.getMetadataInfo(MetadataServiceDubboProxy0.java)
    at org.apache.dubbo.registry.client.metadata.MetadataUtils.getRemoteMetadata(MetadataUtils.java:173)
6

调用结束后 RpcServiceContext 会进行清理,如果有处理需要的话请实现 Filter.Listener 的 onResponse 接口

8

到底是怎么回事。俺也不懂。 image 红框里面报空指针