This is an automated email from the ASF dual-hosted git repository.

chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory.git


The following commit(s) were added to refs/heads/main by this push:
     new ec7b96cbd fix(java): Fix flakiness in 
ForyCopyTest#mutableObjectCopyTest (#2738)
ec7b96cbd is described below

commit ec7b96cbd69a04cb220967d3e33ef543a5767176
Author: JACKDABOSS <[email protected]>
AuthorDate: Thu Oct 9 20:54:52 2025 -0500

    fix(java): Fix flakiness in ForyCopyTest#mutableObjectCopyTest (#2738)
    
    ## What does this PR do?
    
    `ForyCopyTest#mutableObjectCopyTest` assumes that PriorityQueues
    gurrantees natural ordering in its underlying structure, which can lead
    to non-deterministic test results.
    
    > This class and its iterator implement all of the optional methods of
    the
    
[Collection](https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html)
    and
    
[Iterator](https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html)
    interfaces. 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.
    
    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.ForyCopyTest.mutableObjectCopyTest
    ```
    This PR uses `sortedCopyOf()` instead to enforce the ordering of
    elememts in the new ImmutableList, which removes the flakiness.
    
    Similar to #2693
    
    ## Does this PR introduce any user-facing change?
    
    No
---
 java/fory-core/src/test/java/org/apache/fory/ForyCopyTest.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/fory-core/src/test/java/org/apache/fory/ForyCopyTest.java 
b/java/fory-core/src/test/java/org/apache/fory/ForyCopyTest.java
index 5c68851fd..39c512f95 100644
--- a/java/fory-core/src/test/java/org/apache/fory/ForyCopyTest.java
+++ b/java/fory-core/src/test/java/org/apache/fory/ForyCopyTest.java
@@ -243,7 +243,7 @@ public class ForyCopyTest extends ForyTestBase {
     ChildArrayDeque<String> list = new ChildArrayDeque<>();
     list.addAll(data);
     Assert.assertEquals(data, ImmutableList.copyOf(fory.copy(list)));
-    Assert.assertEquals(data, ImmutableList.copyOf(new PriorityQueue<>(data)));
+    Assert.assertEquals(data, ImmutableList.sortedCopyOf(new 
PriorityQueue<>(data)));
   }
 
   private void primitiveCopyTest() {


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

Reply via email to