The GitHub Actions job "Sync Files" on fory.git/main has failed.
Run started by GitHub user chaokunyang (triggered by chaokunyang).

Head commit for run:
15d601c1769560a7051db5fe2c49f2bf38df48e2 / JACKDABOSS 
<[email protected]>
fix(java): Fix flakiness in MetaContextTest#testShareClassName and 
#testShareClassDefCompatible (#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

Report URL: https://github.com/apache/fory/actions/runs/18394125695

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to