Fix: Stabilize map-order assertions in REST protocol tests
What is the purpose of the change?
This PR stabilizes map-related assertions in REST protocol tests that were intermittently failing under randomized execution orders (e.g., NonDex). Specifically, the following tests were affected:
RestProtocolTest.MultivaluedMap testindubbo-plugin/dubbo-rest-jaxrsRestProtocolTest.map argument body testindubbo-plugin/dubbo-rest-spring
These tests failed when map entries were serialized in a different key order, despite the logical content being identical.
Root Cause
The tests relied on strict string or substring comparisons that implicitly assumed a deterministic ordering of map keys in serialized responses. However, JSON object key ordering is not guaranteed, and internal map iteration order may vary due to JVM behavior or NonDex-induced reordering.
Changes Made
- Updated the affected assertions to validate the presence of expected key–value fragments independently, rather than relying on a single ordered JSON substring.
- Preserved existing test structure, inputs, and expected semantics.
Verification
You can try running the following snippet of code from the dubbo repo root, on both pre-fix and post-fix code
For RestProtocolTest.MultivaluedMap test:
./mvnw -q -pl dubbo-plugin/dubbo-rest-jaxrs edu.illinois:nondex-maven-plugin:2.2.1:nondex \
-DnondexRuns=100 \
-Dtest=org.apache.dubbo.rpc.protocol.tri.rest.support.jaxrs.RestProtocolTest
For RestProtocolTest.map argument body test:
./mvnw -q -pl dubbo-plugin/dubbo-rest-spring edu.illinois:nondex-maven-plugin:2.2.1:nondex \
-DnondexRuns=100 \
-Dtest=org.apache.dubbo.rpc.protocol.tri.rest.support.spring.RestProtocolTest
The tests should fail intermittently on the pre-fix version, but pass consistently across all seeds on the post-fix version. NonDex run logs will be available under:
dubbo-plugin/dubbo-rest-jaxrs/.nondexdirectory forRestProtocolTest.MultivaluedMap testdubbo-plugin/dubbo-rest-spring/.nondexdirectory forRestProtocolTest.map argument body test.
Checklist
- [x] Make sure there is a GitHub_issue field for the change.
- [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [x] Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
- [x] Make sure gitHub actions can pass. Why the workflow is failing and how to fix it?
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 60.76%. Comparing base (efed26c) to head (37c57d8).
Additional details and impacted files
@@ Coverage Diff @@
## 3.3 #15849 +/- ##
============================================
- Coverage 60.77% 60.76% -0.02%
+ Complexity 11710 11706 -4
============================================
Files 1938 1938
Lines 88692 88692
Branches 13387 13387
============================================
- Hits 53903 53892 -11
- Misses 29260 29266 +6
- Partials 5529 5534 +5
| Flag | Coverage Δ | |
|---|---|---|
| integration-tests-java21 | 32.37% <ø> (+<0.01%) |
:arrow_up: |
| integration-tests-java8 | 32.44% <ø> (+<0.01%) |
:arrow_up: |
| samples-tests-java21 | 31.99% <ø> (+0.01%) |
:arrow_up: |
| samples-tests-java8 | 29.72% <ø> (+0.02%) |
:arrow_up: |
| unit-tests-java11 | 59.09% <ø> (+0.02%) |
:arrow_up: |
| unit-tests-java17 | 58.57% <ø> (+<0.01%) |
:arrow_up: |
| unit-tests-java21 | 58.57% <ø> (-0.04%) |
:arrow_down: |
| unit-tests-java25 | 58.52% <ø> (-0.01%) |
:arrow_down: |
| unit-tests-java8 | 59.08% <ø> (+0.03%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.