pem70 opened a new pull request, #4974: URL: https://github.com/apache/servicecomb-java-chassis/pull/4974
### Issue The tests `should_encode_register_type()` and `should_encode_unregister_type()` under module `service-registry/registry-lightweight` compare **pretty-printed JSON strings** against hard-coded literals. Because the underlying objects are built using `Map`/`Set` iteration, the **field order in the serialized JSON is non-deterministic** (depends on iteration order and Jackson config). When the order differs from the literal, the string comparison fails, causing **flaky behavior**. These tests were flagged by [**NonDex**](https://github.com/TestingResearchIllinois/NonDex), which detects hidden ordering assumptions. To reproduce on a module that includes these tests (e.g., `service-registry/registry-lightweight`): ```bash mvn -pl service-registry/registry-lightweight edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=org.apache.servicecomb.registry.lightweight.MessageTest.should_encode_register_type ``` ### Affected Tests This change fixes the following tests: - `should_encode_register_type` - `should_encode_unregister_type` *(Both were asserting equality to a pretty-printed JSON literal.)* ### Fix Instead of raw string equality, the tests now perform **structural JSON comparison** using Jackson trees (`ObjectMapper.readTree(...)` + `JsonNode` equality). This makes the assertions **order-insensitive** and removes the non-determinism. I also added minimal exception handling to fail with clear context if parsing ever fails. Rerunning NonDex with this change yields **stable passing** results. ### PR Checklist - [x] **GitHub Issue:** [[BUG] Flaky JSON-order tests in register/unregister encoding (#XXXX)](https://github.com/apache/servicecomb-java-chassis/issues/XXXX) - [x] Each commit in the pull request has a meaningful subject and body. - [x] Ran `mvn clean install -Pit` to ensure basic checks pass (CI will run additional checks). - [x] PR title formatted like `[SCB-XXX] Make register/unregister JSON tests order-insensitive` (replace `SCB-XXX` with the appropriate JIRA). - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. -- 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]
