bajiaoshan opened a new issue, #16535:
URL: https://github.com/apache/dubbo/issues/16535
### Pre-check
- [x] All content is in English.
- [x] Searched existing issues and open pull requests; no matching fix was
found.
### Apache Dubbo Component
Java SDK (apache/dubbo)
### Dubbo Version
3.3.7-SNAPSHOT, branch `3.3`, commit
`843b98b3a1c70134e965ab04efc2de668238e0b2`.
Windows 11, Eclipse Temurin JDK 17.0.20.1, Maven 3.9.14.
### Steps to reproduce this issue
Merging two application configurations with `OVERRIDE_ALL` or
`OVERRIDE_IF_ABSENT` calls `AbstractConfig.overrideWithConfig`. The following
isolates the same merge:
```java
ApplicationConfig target = new ApplicationConfig("app");
target.setParameters(Collections.singletonMap("old-only", "old-value"));
ApplicationConfig incoming = new ApplicationConfig("app");
incoming.setParameters(Collections.singletonMap("new-only", "new-value"));
target.overrideWithConfig(incoming, true);
```
Use imports `org.apache.dubbo.config.ApplicationConfig` and
`java.util.Collections`.
The merge fails with `IllegalStateException` caused by
`UnsupportedOperationException`: `oldMap.forEach(newMap::putIfAbsent)` writes
into the incoming, read-only map. Passing `false` fails at
`newMap.putAll(oldMap)` instead.
With a mutable incoming map, the merge completes but adds `old-only` to that
map. In `OVERRIDE_IF_ABSENT`, values for overlapping keys in the incoming
configuration are also overwritten by the target's values.
### What you expected to happen
The target should receive the merged parameters, respecting the selected
mode's precedence. The incoming configuration and its caller-provided map
should retain their original entries. Providing read-only parameters should not
prevent the merge.
### Anything else
Four parameterized regression cases reproduce both behaviors through
`ConfigManager.addConfig`: two modes, each with mutable or unmodifiable
incoming parameters. On the original code, two cases fail source-map assertions
and two error with `UnsupportedOperationException`. Copying the incoming map
before merging makes all four pass, while retaining the existing key precedence.
### Are you willing to submit a pull request?
Yes. A minimal fix and regression tests are prepared.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]