You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by up...@apache.org on 2018/11/28 17:24:19 UTC
[geode] branch develop updated: GEODE-6077: Fixing race in test hook
This is an automated email from the ASF dual-hosted git repository.
upthewaterspout pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new d80b6e0 GEODE-6077: Fixing race in test hook
d80b6e0 is described below
commit d80b6e0c0dfea780d3b45651d578082d743bd763
Author: Dan Smith <up...@apache.org>
AuthorDate: Mon Nov 26 15:05:35 2018 -0800
GEODE-6077: Fixing race in test hook
IndexOnEntrySetJUnitTest was using wait/notify in an unsafe way - if
the wait happened before the notify, it would never be interrupted.
For some reason the test wanted to do the test hook in a separate
thread, maybe due to thread locals? Still running the hook in a separate
thread, but using CompletableFuture which will do the right thing and
also report exceptions that happened in the hook.
---
.../query/functional/IndexOnEntrySetJUnitTest.java | 21 +++------------------
1 file changed, 3 insertions(+), 18 deletions(-)
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/cache/query/functional/IndexOnEntrySetJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/cache/query/functional/IndexOnEntrySetJUnitTest.java
index c3338ba..b4f2e62 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/cache/query/functional/IndexOnEntrySetJUnitTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/cache/query/functional/IndexOnEntrySetJUnitTest.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertTrue;
import java.text.ParseException;
import java.util.Collection;
import java.util.Iterator;
+import java.util.concurrent.CompletableFuture;
import org.junit.After;
import org.junit.Before;
@@ -284,7 +285,6 @@ public class IndexOnEntrySetJUnitTest {
*/
abstract class AbstractTestHook implements IndexManager.TestHook {
boolean isTestHookCalled = false;
- Object waitObj = new Object();
Region r;
private int testHookSpot;
@@ -307,28 +307,13 @@ public class IndexOnEntrySetJUnitTest {
public abstract void doOp();
@Override
- public void hook(int spot) throws RuntimeException {
+ public void hook(int spot) {
if (spot == testHookSpot) {
if (!isTestHookCalled) {
isTestHookCalled = true;
- try {
- new Thread(new Runnable() {
- public void run() {
- doOp();
- synchronized (waitObj) {
- waitObj.notifyAll();
- }
- }
- }).start();
- synchronized (waitObj) {
- waitObj.wait();
- }
- } catch (InterruptedException e) {
- throw new Error(e);
- }
+ CompletableFuture.runAsync(this::doOp).join();
}
}
-
}
}