Skip to content

[3.0-Triple] Application service discovery had broken down because of consumerModel's NPE in TripleClientHandler #8733

@plusmancn

Description

@plusmancn
  • 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.

Because of TripleClientHandler working in a new thread, The line url.getServiceMode doesn't work in TripleClientHandler with InstanceAddressURL when we try to use application-service-discovery.

// => org.apache.dubbo.rpc.protocol.tri.TripleClientHandler#writeRequest
private void writeRequest(ChannelHandlerContext ctx, final Request req, final ChannelPromise promise) {
    final RpcInvocation inv = (RpcInvocation) req.getData();
    final URL url = inv.getInvoker().getUrl();
    // Here will throw NPE
    ConsumerModel consumerModel = (ConsumerModel) url.getServiceModel();
    // ......
}

See InstanceAddressURL:

// => org.apache.dubbo.registry.client.InstanceAddressURL#getServiceModel
public ServiceModel getServiceModel() {
    return RpcContext.getServiceContext().getConsumerUrl().getServiceModel();
}

// => org.apache.dubbo.rpc.RpcContext
private static final InternalThreadLocal<RpcServiceContext> SERVICE_CONTEXT = new InternalThreadLocal<RpcServiceContext>() {
    @Override
    protected RpcServiceContext initialValue() {
        return new RpcServiceContext();
    }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions