Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X 65d52ee53 -> 16f908652


Workaround the wield issue of `MemoizeTest`

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


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 16f9086526052fca9be08dcc7f75144467022c4e
Parents: 65d52ee
Author: danielsun1106 <realblue...@hotmail.com>
Authored: Sat Mar 3 10:41:40 2018 +0800
Committer: danielsun1106 <realblue...@hotmail.com>
Committed: Sat Mar 3 10:41:40 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/16f90865/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