You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2019/07/31 15:34:18 UTC

[tinkerpop] 01/04: Made iterator leak check a bit more relaxed CTR

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

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 56fc12eb09b9ca094ed1370271104f0755cc856d
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Wed Jul 31 11:31:45 2019 -0400

    Made iterator leak check a bit more relaxed CTR
---
 .../apache/tinkerpop/gremlin/AbstractGremlinTest.java   | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
index 9bfbc7b..5d0faee 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
@@ -138,11 +138,6 @@ public abstract class AbstractGremlinTest {
         if (null != graphProvider) {
             graphProvider.getTestListener().ifPresent(l -> l.onTestEnd(this.getClass(), name.getMethodName()));
 
-            if (shouldTestIteratorLeak) {
-                final long openItrCount = StoreIteratorCounter.INSTANCE.getOpenIteratorCount();
-                assertEquals("Iterator leak detected. Open iterator count=" + openItrCount, 0, openItrCount);
-            }
-
             // GraphProvider that has implemented the clear method must check null for graph and config.
             graphProvider.clear(graph, config);
 
@@ -154,6 +149,18 @@ public abstract class AbstractGremlinTest {
             else
                 logger.warn("The {} is not of type ManagedGraphProvider and therefore graph instances may leak between test cases.", graphProvider.getClass());
 
+            if (shouldTestIteratorLeak) {
+                long wait = 300;
+                long[] tries = new long[] { 1, 3, 5, 7, 9, 18, 27, 36, 72, 144, 256, 512 };
+                long openItrCount = StoreIteratorCounter.INSTANCE.getOpenIteratorCount();
+                for (int ix = 0; ix < tries.length && openItrCount > 0; ix++) {
+                    Thread.sleep(wait * tries[ix]);
+                    openItrCount = StoreIteratorCounter.INSTANCE.getOpenIteratorCount();
+                }
+
+                assertEquals("Iterator leak detected. Open iterator count=" + openItrCount, 0, openItrCount);
+            }
+
             g = null;
             graph = null;
             config = null;