You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fory.apache.org by "swj20010308 (via GitHub)" <gi...@apache.org> on 2025/10/20 17:41:55 UTC
[PR] fix(java): Fix flakiness in CollectionSerializersTest#testCollectionFieldSerializers, CollectionSerializersTest#testCollectionFieldSerializersCopy and ProtocolInteroperabilityTest#testComplexCollection [fory]
swj20010308 opened a new pull request, #2790:
URL: https://github.com/apache/fory/pull/2790
## What does this PR do?
These tests create a `CollectionFieldsClass` that contains HashSet and PriorityQueue fields, which do not guarantee deterministic ordering. So `toString()` comparisons could lead to non-deterministic failures.
Quotes from Java's summary of HashSet and PriorityQueue:
> It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time.
> The Iterator provided in method [iterator()](https://docs.oracle.com/javase/8/docs/api/java/util/PriorityQueue.html#iterator--) is not guaranteed to traverse the elements of the priority queue in any particular order. If you need ordered traversal, consider using Arrays.sort(pq.toArray()).
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.serializer.collection.CollectionSerializersTest#testCollectionFieldSerializers
mvn -pl fory-core edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=org.apache.fory.serializer.collection.CollectionSerializersTest#testCollectionFieldSerializersCopy
mvn -pl fory-core edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=org.apache.fory.serializer.ProtocolInteroperabilityTest#testComplexCollection
```
Since `toString()` just dumps all the fields, we can solve the problem by iteratively comparing fields with deterministic ordering, and manually compare everything else after sorting.
In particular, `CollectionSerializersTest.testCollectionFieldsObjectEqual` is made public, so that `ProtocolInteroperabilityTest` can reuse the solution.
## 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: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(java): Fix flakiness in CollectionSerializersTest#testCollectionFieldSerializers, CollectionSerializersTest#testCollectionFieldSerializersCopy and ProtocolInteroperabilityTest#testComplexCollection [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang merged PR #2790:
URL: https://github.com/apache/fory/pull/2790
--
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: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org