<ul dir="auto">
<li>[*] I have searched the <a href="https://github.com/apache/dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li>[*] I have checked the <a href="https://github.com/apache/dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: 2.7.2</li>
<li>Operating System version: windows10(18362.175)</li>
<li>Java version: jdk12.0.1</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>create interface</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@SPI
public interface Robot {
    void sayHello();
}"><pre class="notranslate"><code class="notranslate">@SPI
public interface Robot {
    void sayHello();
}
</code></pre></div>
<ol start="2" dir="auto">
<li>implements Roobot</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="public class Bumblebee implements Robot {

    @Override
    public void sayHello() {
        System.out.println(&quot;Hello, I am Bumblebee.&quot;);
    }
}

public class OptimusPrime implements Robot {

    @Override
    public void sayHello() {
        System.out.println(&quot;Hello, I am Optimus Prime.&quot;);
    }
}"><pre class="notranslate"><code class="notranslate">public class Bumblebee implements Robot {

    @Override
    public void sayHello() {
        System.out.println("Hello, I am Bumblebee.");
    }
}

public class OptimusPrime implements Robot {

    @Override
    public void sayHello() {
        System.out.println("Hello, I am Optimus Prime.");
    }
}
</code></pre></div>
<ol start="3" dir="auto">
<li>create a folder<br>
<code class="notranslate">/MEAT-INF/dubbo/</code></li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="optimusPrime=com.huifer.dubbo.client.spi.OptimusPrime
bumblebee=com.huifer.dubbo.client.spi.Bumblebee
"><pre class="notranslate"><code class="notranslate">optimusPrime=com.huifer.dubbo.client.spi.OptimusPrime
bumblebee=com.huifer.dubbo.client.spi.Bumblebee

</code></pre></div>
<ol start="4" dir="auto">
<li>run demo</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="public class SpiDemo {

    public static void main(String[] args) {

        ExtensionLoader&lt;Robot&gt; extensionLoader =
                ExtensionLoader.getExtensionLoader(Robot.class);
        Robot optimusPrime = extensionLoader.getExtension(&quot;optimusPrime&quot;);
        optimusPrime.sayHello();
        Robot bumblebee = extensionLoader.getExtension(&quot;bumblebee&quot;);
        bumblebee.sayHello();

    }

}"><pre class="notranslate"><code class="notranslate">public class SpiDemo {

    public static void main(String[] args) {

        ExtensionLoader&lt;Robot&gt; extensionLoader =
                ExtensionLoader.getExtensionLoader(Robot.class);
        Robot optimusPrime = extensionLoader.getExtension("optimusPrime");
        optimusPrime.sayHello();
        Robot bumblebee = extensionLoader.getExtension("bumblebee");
        bumblebee.sayHello();

    }

}
</code></pre></div>
<p dir="auto">Pls. provide <a href="https://github.com/huifer/javaBook-src/tree/master/distributed/dubbo/dubbo-client/src/main/java/com/huifer/dubbo/client/spi">GitHub address</a> to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">Console output</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Hello, I am Optimus Prime.
Hello, I am Bumblebee."><pre class="notranslate"><code class="notranslate">Hello, I am Optimus Prime.
Hello, I am Bumblebee.
</code></pre></div>
<h3 dir="auto">Actual Result</h3>
<ul dir="auto">
<li>It has an exception and does not find optimusPrime</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Exception in thread &quot;main&quot; java.lang.IllegalStateException: No such extension com.huifer.dubbo.client.spi.Robot by name optimusPrime
	at org.apache.dubbo.common.extension.ExtensionLoader.findException(ExtensionLoader.java:520)
	at org.apache.dubbo.common.extension.ExtensionLoader.createExtension(ExtensionLoader.java:527)
	at org.apache.dubbo.common.extension.ExtensionLoader.getExtension(ExtensionLoader.java:351)
	at com.huifer.dubbo.client.spi.SpiDemo.main(SpiDemo.java:18)
"><pre class="notranslate"><code class="notranslate">Exception in thread "main" java.lang.IllegalStateException: No such extension com.huifer.dubbo.client.spi.Robot by name optimusPrime
	at org.apache.dubbo.common.extension.ExtensionLoader.findException(ExtensionLoader.java:520)
	at org.apache.dubbo.common.extension.ExtensionLoader.createExtension(ExtensionLoader.java:527)
	at org.apache.dubbo.common.extension.ExtensionLoader.getExtension(ExtensionLoader.java:351)
	at com.huifer.dubbo.client.spi.SpiDemo.main(SpiDemo.java:18)

</code></pre></div>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/apache/dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/apache/dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: 2.7.1</li>
<li>Operating System version: Windows</li>
<li>Java version: 1.8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<p dir="auto">When I config <code class="notranslate">TagRouter</code> like this (in Dubbo admin):</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="enabled: true
force: false
runtime: false
tags:
  - name: tag1
    addresses: null
  - name: tag2
    addresses: null"><pre class="notranslate"><span class="pl-ent">enabled</span>: <span class="pl-c1">true</span>
<span class="pl-ent">force</span>: <span class="pl-c1">false</span>
<span class="pl-ent">runtime</span>: <span class="pl-c1">false</span>
<span class="pl-ent">tags</span>:
  - <span class="pl-ent">name</span>: <span class="pl-s">tag1</span>
    <span class="pl-ent">addresses</span>: <span class="pl-c1">null</span>
  - <span class="pl-ent">name</span>: <span class="pl-s">tag2</span>
    <span class="pl-ent">addresses</span>: <span class="pl-c1">null</span></pre></div>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">Then the <code class="notranslate">java.lang.NullPointerException</code> was caused</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="java.lang.NullPointerException
	at org.apache.dubbo.rpc.cluster.router.tag.model.TagRouterRule.lambda$init$2(TagRouterRule.java:55)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at org.apache.dubbo.rpc.cluster.router.tag.model.TagRouterRule.init(TagRouterRule.java:53)
	at org.apache.dubbo.rpc.cluster.router.tag.model.TagRuleParser.parse(TagRuleParser.java:42)"><pre class="notranslate"><code class="notranslate">java.lang.NullPointerException
	at org.apache.dubbo.rpc.cluster.router.tag.model.TagRouterRule.lambda$init$2(TagRouterRule.java:55)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at org.apache.dubbo.rpc.cluster.router.tag.model.TagRouterRule.init(TagRouterRule.java:53)
	at org.apache.dubbo.rpc.cluster.router.tag.model.TagRuleParser.parse(TagRuleParser.java:42)
</code></pre></div>
<p dir="auto">I think we should add NPE check in <code class="notranslate">TagRouterRule</code> or check <code class="notranslate">addresses </code> in Dubbo admin</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="tags.forEach(tag -&gt; {
    tagnameToAddresses.put(tag.getName(), tag.getAddresses());
   // check  tag.getAddresses() not null
    tag.getAddresses().forEach(addr -&gt; {
        List&lt;String&gt; tagNames = addressToTagnames.computeIfAbsent(addr, k -&gt; new ArrayList&lt;&gt;());
        tagNames.add(tag.getName());
    });
});"><pre class="notranslate"><span class="pl-s1">tags</span>.<span class="pl-en">forEach</span>(<span class="pl-s1">tag</span> -&gt; {
    <span class="pl-s1">tagnameToAddresses</span>.<span class="pl-en">put</span>(<span class="pl-s1">tag</span>.<span class="pl-en">getName</span>(), <span class="pl-s1">tag</span>.<span class="pl-en">getAddresses</span>());
   <span class="pl-c">// check  tag.getAddresses() not null</span>
    <span class="pl-s1">tag</span>.<span class="pl-en">getAddresses</span>().<span class="pl-en">forEach</span>(<span class="pl-s1">addr</span> -&gt; {
        <span class="pl-smi">List</span>&lt;<span class="pl-smi">String</span>&gt; <span class="pl-s1">tagNames</span> = <span class="pl-s1">addressToTagnames</span>.<span class="pl-en">computeIfAbsent</span>(<span class="pl-s1">addr</span>, <span class="pl-s1">k</span> -&gt; <span class="pl-k">new</span> <span class="pl-smi">ArrayList</span>&lt;&gt;());
        <span class="pl-s1">tagNames</span>.<span class="pl-en">add</span>(<span class="pl-s1">tag</span>.<span class="pl-en">getName</span>());
    });
});</pre></div>