yonghanlin opened a new pull request, #6232:
URL: https://github.com/apache/shenyu/pull/6232

   ## What does this PR do?
   This PR fixes ```testBuildHandle``` failures in the ```shenyu-admin``` 
module caused by nondeterministic behavior exposed by NonDex in the following 
test classes:
   
   - ShenyuClientRegisterDubboServiceImplTest
   - ShenyuClientRegisterTarsServiceImplTest
   - ShenyuClientRegisterGrpcServiceImplTest
   - ShenyuClientRegisterDivideServiceImplTest
   
   ## Problem
   ```testBuildHandle``` in these tests assumes a fixed JSON property order by 
doing a raw JSON string comparison, but the production code serializes from an 
unordered collection, whose iteration order is randomized by NonDex, causing 
the failures.
   
   ## Reproduce Failure
   To reproduce the failures, run NonDex on ```shenyu-admin``` module using the 
following commands:
   ```
   mvn -pl shenyu-admin test 
-Dtest=org.apache.shenyu.admin.service.register.<TEST_CLASS>#testBuildHandle
   ```
   Replace <TEST_CLASS> with one of:
   ```
   ShenyuClientRegisterDubboServiceImplTest
   ShenyuClientRegisterTarsServiceImplTest
   ShenyuClientRegisterGrpcServiceImplTest
   ShenyuClientRegisterDivideServiceImplTest
   ```
   
   ## The Fix
   The fix works by replacing raw string comparison with a comparison of parsed 
objects. Instead of asserting ```expected``` and ```actual``` JSON strings are 
identical, both are parsed using ```GsonUtils.fromCurrentList(...)``` into 
```List<>```. During parsing, Gson binds fields by their names rather than by 
their textual position in the JSON, so it produces consistent objects even when 
the JSON field order varies.
   
   ## Other
   - [x] You have read the [contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide).
   - [x] You submit test cases (unit or integration tests) that back your 
changes.
   - [x] Your local test passed `./mvnw clean install 
-Dmaven.javadoc.skip=true`.
   


-- 
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]

Reply via email to