Skip to content

NullPointerException could be Thrown at line 124 of org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalance #10403

@zhaoyangyingmu

Description

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

Environment

  • Dubbo version: 3.0
  • Operating System version: Any
  • Java version: 1.8

Steps to reproduce this issue

An NPE could be thrown at line 124 of org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalance. selectedWRR could be null because the condition cur > maxCurrent may not be true.

    protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) {
        WeightedRoundRobin selectedWRR = null;
        // other codes
        for (Invoker<T> invoker : invokers) {
            // other codes
            if (cur > maxCurrent) {
                selectedWRR = weightedRoundRobin;
            }
        }
        if (selectedInvoker != null) {
            selectedWRR.sel(totalWeight); // selectedWRR could be null.
            return selectedInvoker;
        }

Actual Behavior

An NPE could be thrown at line 124 because no defensive null check is provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugBugs to being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions