You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by GitBox <gi...@apache.org> on 2021/11/18 20:04:53 UTC

[GitHub] [cayenne] shunfan-shao opened a new pull request #472: Fix concurrent map flakiness

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: commits-unsubscribe@cayenne.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org