swj20010308 opened a new pull request, #2739:
URL: https://github.com/apache/fory/pull/2739

   ## What does this PR do?
   
   These tests in `MetaContextTest` create a `BeanA` instance for testing, 
which contains a HashMap. When calling `write(MemoryBuffer buffer, T value)` in 
`MapLikeSerializer.java`, the method assumes that the HashMap maintains 
constant ordering of elements. This can cause 
`Assert.assertEquals(fory.serialize(o), bytes)` to fail non-deterministically 
in `MetaContextTest.java`. This PR is similar to #2692. 
   
   > This class makes no guarantees as to the order of the map; in particular, 
it does not guarantee that the order will remain constant over time.
   
   We can reproduce the flakiness with 
[NonDex](https://github.com/TestingResearchIllinois/NonDex):
   ```
   mvn -pl fory-core edu.illinois:nondex-maven-plugin:2.1.7:nondex 
-Dtest=org.apache.fory.resolver.MetaContextTest#testShareClassName
   
   mvn -pl fory-core edu.illinois:nondex-maven-plugin:2.1.7:nondex 
-Dtest=org.apache.fory.resolver.MetaContextTest#testShareClassDefCompatible
   ```
   
   We can trace the HashMap causing failures with 
   ```
   mvn -pl fory-core edu.illinois:nondex-maven-plugin:2.1.7:debug
   ```
   
   This PR solves the issue by using a LinkedHashMap in `BeanA` which promises 
deterministic ordering.
   
   ## Does this PR introduce any user-facing change?
   
   No
   


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

Reply via email to