Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X 08a07e3b3 -> c89e32518


Workaround the wield issue of `MemoizeTest`

```
// EXECUTION_COUNT is AtomicInteger
assert 2 == Utils.EXECUTION_COUNT.get()
         |        |               |
         false    2               1
```

(cherry picked from commit 16f9086)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/b4dd8397
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/b4dd8397
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/b4dd8397

Branch: refs/heads/GROOVY_2_5_X
Commit: b4dd8397104e8c99cf8af8c38b7b4d47b4c6f99a
Parents: 08a07e3
Author: danielsun1106 <[email protected]>
Authored: Sat Mar 3 10:41:40 2018 +0800
Committer: danielsun1106 <[email protected]>
Committed: Sat Mar 3 20:31:53 2018 +0800

----------------------------------------------------------------------
 .../groovy/runtime/memoize/MemoizeTest.groovy       | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/b4dd8397/src/test/org/codehaus/groovy/runtime/memoize/MemoizeTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/memoize/MemoizeTest.groovy 
b/src/test/org/codehaus/groovy/runtime/memoize/MemoizeTest.groovy
index 7c74463..db91778 100644
--- a/src/test/org/codehaus/groovy/runtime/memoize/MemoizeTest.groovy
+++ b/src/test/org/codehaus/groovy/runtime/memoize/MemoizeTest.groovy
@@ -126,13 +126,19 @@ public class MemoizeTest extends AbstractMemoizeTestCase {
         assertScript '''
         // 
http://groovy.329449.n5.nabble.com/ConcurrentModificationException-with-use-of-memoize-tp5736788.html
         
-        import java.util.concurrent.atomic.AtomicInteger
-        
         class Utils { 
-            public static final AtomicInteger EXECUTION_COUNT = new 
AtomicInteger(0)
+            public static int cnt = 0
+            
+            public static synchronized void increment() {
+                cnt++
+            }
+            
+            public static synchronized int getCnt() {
+                return cnt
+            }
         
             public static final Closure powerSet =  { Collection things -> 
-                EXECUTION_COUNT.incrementAndGet()
+                increment()
         
                 def Set objSets = things.collect { [it] as Set } 
                 def Set resultSet = [[] as Set] 
@@ -179,7 +185,7 @@ public class MemoizeTest extends AbstractMemoizeTestCase {
         
         threadList*.join()
         
-        assert 2 == Utils.EXECUTION_COUNT.get()
+        assert 2 == Utils.getCnt()
         '''
     }
 

Reply via email to