shunfan-shao opened a new pull request #472:
URL: https://github.com/apache/cayenne/pull/472


   # Description
   Test `org.apache.cayenne.util.WeakValueMapTest.testConcurrentModification` 
will fail under [NonDex](https://github.com/TestingResearchIllinois/NonDex) 
which detects flakiness under non-deterministic environment. 
   
   To reproduce:
   ```
   mvn edu.illinois:nondex-maven-plugin:1.1.2:nondex \
       -pl cayenne-server \
       
-Dtest=org.apache.cayenne.util.WeakValueMapTest#testConcurrentModification
   ```
   
   # Issue
   The test code follows the logic below:
   ```java
   Map<String, Integer> map = new WeakValueMap<>(3);
   for(Map.Entry<String, Integer> entry : map.entrySet()) {
       if("key_2".equals(entry.getKey())) 
           map.remove("key_2");
   }
   ```
   
   While [WeakValueMap uses HashMap 
internally](https://github.com/apache/cayenne/blob/master/cayenne-server/src/main/java/org/apache/cayenne/util/ReferenceMap.java#L76),
 it is not guaranteed for `map.entrySet` to iterate over the entries under some 
orders.
   
   The code is expected to thrown `ConcurrentModificationException` during 
execution. Under some edge cases, eg: `key_2` is traversed and removed last, 
the test will fail to throw and cause an issue. 


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