-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Description
- 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: 2.7.3
- Operating System version: windows8
- Java version: 1.8
Steps to reproduce this issue
-
在消费端使用注解@reference时候,其中registry中指定了具体的值(注册配置对应的id属性)后,在启动解析注解时候,会执行configureRegistryConfigs方法解析@reference中的registry属性值,在改属性里面设置了值后,会执行getBeans方法,在getBeans方法中会返回Collections.unmodifiableList集合
-
在步骤1中返回的集合,会在接下来调用相应的ReferenceBean的方法setRegistries,设置到属性List registries中,此时的list是Collections.unmodifiableList实现。
-
接下来,在ReferenceBean初始化中,会先检测注册配置,调用checkRegistry方法,在里面会将RegistryIds 转换为registries,即在convertRegistryIdsToRegistries方法中完成。
-
convertRegistryIdsToRegistries 方法在有registryIds时候,有如下代码:
String[] ids = COMMA_SPLIT_PATTERN.split(registryIds); List<RegistryConfig> tmpRegistries = CollectionUtils.isNotEmpty(registries) ? registries : new ArrayList<>(); Arrays.stream(ids).forEach(id -> { if (tmpRegistries.stream().noneMatch(reg -> reg.getId().equals(id))) { tmpRegistries.add(ConfigManager.getInstance().getRegistry(id).orElseGet(() -> { RegistryConfig registryConfig = new RegistryConfig(); registryConfig.setId(id); registryConfig.refresh(); return registryConfig; })); } });
其中tmpRegistries.add时候会报错,因为此时的tmpRegistries是Collections.unmodifiableList实例,导致无法添加
Pls. provide [GitHub address] to reproduce this issue.