apache / apache/dubbo

混合配置导致的Invalid name="org.apache.dubbo.config.ApplicationConfig#0"问题

Open
#6,202 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

- [ ] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
- [ ] I have checked the [FAQ](https://github.com/apache/dubbo/blob/master/FAQ.md) of this repository and believe that this is not a duplicate.

### Environment

* Dubbo version: 2.7.2
* Operating System version: macOS
* Java version: 1.8

### Steps to reproduce this issue

1. 使用java配置的方式配置config类:
@Bean
public ApplicationConfig applicationConfig(@Qualifier("registryConfig") RegistryConfig registryConfig, @Qualifier("monitorConfig") MonitorConfig monitorConfig) {
ApplicationConfig applicationConfig = new ApplicationConfig();
applicationConfig.setName("balance-consumer");
applicationConfig.setMonitor(monitorConfig);
return applicationConfig;
}
2. 在environment配置-Ddubbo.application.owner=xxx或者在springboot的application.properties中不配置dubbo.application.id或者dubbo.application.name。
3. 正常启动。

Pls. provide [GitHub address] to reproduce this issue.

### Expected Result

What do you expected from the above steps?
正常启动。
### Actual Result

What actually happens?
抛出异常:
Caused by: java.lang.IllegalStateException: Invalid name="org.apache.dubbo.config.ApplicationConfig#0" contains illegal character, only digit, letter, '-', '_' or '.' is legal

已经check过其他几个相关的issue,里面都是没有配置对应的name和id导致。
此issue关注点为,在使用java配置了applicationConfig后,如果在其他位置有dubbo.application开头的配置,则会额外由spring生成新的applicationConfig,导致以上异常。

尝试过issue中建议的增加dubbo.application.name或者id,则抛出
Duplicate application configs
异常。

问题是由于dubbo.application触发的applicationConfig和直接配置的applicationConfig不是同一个实例引起的,建议在dubbo.application和java方式配置的applicationConfig之间设定优先级。

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Java configuration with ApplicationConfig and a dubbo.application.owner setting in Spring Boot application.properties on Dubbo 2.7.2. Trace how these settings create ApplicationConfig instances; done means startup succeeds without the invalid generated name or a duplicate application-configuration error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.