Issue 1:
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.

Environment

Dubbo version: latest master branch

Operating System version: macos

Java version: 1.8

Description

in ChannelEventRunnable#run there is a switch-case fall through which is introduced in b3e91fa .

I believe this is a little mistake, and UT is not necessary.

As shown below, there is no break statement after SENT, I will send a pr later.

...
case DISCONNECTED:
try {
handler.disconnected(channel);
} catch (Exception e) {
logger.warn("ChannelEventRunnable handle " + state + " operation error, channel is " + channel, e);
}
break;
case SENT:
try {
handler.sent(channel, message);
} catch (Exception e) {
logger.warn("ChannelEventRunnable handle " + state + " operation error, channel is " + channel
+ ", message is " + message, e);
}
// no break statement here!
case CAUGHT:
try {
handler.caught(channel, exception);
} catch (Exception e) {
logger.warn("ChannelEventRunnable handle " + state + " operation error, channel is " + channel
+ ", message is: " + message + ", exception is " + exception, e);
}
break;
default:
logger.warn("unknown state: " + state + ", message is " + message);
}

Issue 2:
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.

Environment

Dubbo version: reproduced with 2.7.3, 2.7.8

Operating System version: Windows 10

Java version: 1.8.0

Steps to reproduce this issue

Register a service with a non-dubbo service name (e.g. user-service) in a Nacos registry

Start a dubbo provider registering to the same Nacos registry

Start a dubbo consumer consuming the service provided by the former provider, with a wildcard selector ('*') in group or version

Expected Result

The consumer can initialize and call services successfully.

Actual Result

What actually happens?

The consumer aborted during initialization, with the following exception:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demoServiceComponent': Injection of @DubboReference dependencies is failed; nested exception is java.lang.IllegalStateException: Failed to subscribe consumer://192.168.1.241/org.apache.dubbo.demo.DemoService?application=dubbo-demo-annotation-consumer&category=providers,configurators,routers&dubbo=2.0.2&group=*&init=false&interface=org.apache.dubbo.demo.DemoService&methods=sayHello,sayHelloAsync&pid=10232&side=consumer&sticky=false&timestamp=1603163878386, cause: 1
at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.postProcessPropertyValues(AbstractAnnotationBeanPostProcessor.java:146)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1268)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84)
at org.apache.dubbo.demo.consumer.Application.main(Application.java:34)
Caused by: java.lang.IllegalStateException: Failed to subscribe consumer://192.168.1.241/org.apache.dubbo.demo.DemoService?application=dubbo-demo-annotation-consumer&category=providers,configurators,routers&dubbo=2.0.2&group=*&init=false&interface=org.apache.dubbo.demo.DemoService&methods=sayHello,sayHelloAsync&pid=10232&side=consumer&sticky=false&timestamp=1603163878386, cause: 1
at org.apache.dubbo.registry.support.FailbackRegistry.subscribe(FailbackRegistry.java:350)
at org.apache.dubbo.registry.ListenerRegistryWrapper.subscribe(ListenerRegistryWrapper.java:105)
at org.apache.dubbo.registry.integration.RegistryDirectory.subscribe(RegistryDirectory.java:185)
at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:469)
at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:449)
at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:72)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:161)
at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java)
at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:356)
at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:296)
at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:200)
at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.doGetInjectedBean(ReferenceAnnotationBeanPostProcessor.java:144)
at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.getInjectedObject(AbstractAnnotationBeanPostProcessor.java:359)
at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor$AnnotatedFieldElement.inject(AbstractAnnotationBeanPostProcessor.java:539)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.postProcessPropertyValues(AbstractAnnotationBeanPostProcessor.java:142)
... 12 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at org.apache.dubbo.registry.nacos.NacosServiceName.<init>(NacosServiceName.java:80)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at org.apache.dubbo.registry.nacos.NacosRegistry.lambda$filterServiceNames$4(NacosRegistry.java:303)
at org.apache.dubbo.registry.nacos.NacosRegistry.execute(NacosRegistry.java:583)
at org.apache.dubbo.registry.nacos.NacosRegistry.filterServiceNames(NacosRegistry.java:295)
at org.apache.dubbo.registry.nacos.NacosRegistry.getServiceNames0(NacosRegistry.java:286)
at org.apache.dubbo.registry.nacos.NacosRegistry.getServiceNames(NacosRegistry.java:267)
at org.apache.dubbo.registry.nacos.NacosRegistry.doSubscribe(NacosRegistry.java:178)
at org.apache.dubbo.registry.support.FailbackRegistry.subscribe(FailbackRegistry.java:333)
... 27 more

Root Cause

When NacosRegistry tries to subscribe dubbo services with wildcard in group or version, it will fetch and parse all service names from nacos. However the parsing logic made a wrong assumption that all services names conform to the dubbo service format like providers:org.apache.dubbo.demo.DemoService:1.0.0:group1, while there may be other service names like user-service in the registry.