GEODE-2386 Don't call System.setProperties(null) when rule is used twice Fixing DistributedRestoreSystemProperties rule so that if the rule is included twice within a test, it does not end up calling System.setProperties(null). That will prevent us from losing the value of java.class.path set by gradle.
Reverting the workaround that didn't actually work. Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/9de114f9 Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/9de114f9 Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/9de114f9 Branch: refs/heads/master Commit: 9de114f9fcdaed61caffcd1775eb2fd8a142a1b5 Parents: 4763a5b Author: Dan Smith <[email protected]> Authored: Thu Feb 2 13:34:13 2017 -0800 Committer: Dan Smith <[email protected]> Committed: Fri Feb 3 10:40:25 2017 -0800 ---------------------------------------------------------------------- .../DistributedRestoreSystemProperties.java | 12 ++++++++---- .../test/dunit/standalone/ProcessManager.java | 20 +------------------- 2 files changed, 9 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/9de114f9/geode-core/src/test/java/org/apache/geode/test/dunit/rules/DistributedRestoreSystemProperties.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/DistributedRestoreSystemProperties.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/DistributedRestoreSystemProperties.java index 7e6198e..322d0c6 100755 --- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/DistributedRestoreSystemProperties.java +++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/DistributedRestoreSystemProperties.java @@ -49,8 +49,10 @@ public class DistributedRestoreSystemProperties extends RestoreSystemProperties this.invoker.invokeInEveryVM(new SerializableRunnable() { @Override public void run() { - originalProperties = getProperties(); - setProperties(new Properties(originalProperties)); + if (originalProperties == null) { + originalProperties = getProperties(); + setProperties(new Properties(originalProperties)); + } } }); } @@ -61,8 +63,10 @@ public class DistributedRestoreSystemProperties extends RestoreSystemProperties this.invoker.invokeInEveryVM(new SerializableRunnable() { @Override public void run() { - setProperties(originalProperties); - originalProperties = null; + if (originalProperties != null) { + setProperties(originalProperties); + originalProperties = null; + } } }); } http://git-wip-us.apache.org/repos/asf/geode/blob/9de114f9/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/ProcessManager.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/ProcessManager.java b/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/ProcessManager.java index 3b02b4b..d7b15fc 100644 --- a/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/ProcessManager.java +++ b/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/ProcessManager.java @@ -16,8 +16,6 @@ package org.apache.geode.test.dunit.standalone; import static org.apache.geode.distributed.ConfigurationProperties.*; -import com.jayway.awaitility.Awaitility; - import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -34,7 +32,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.TimeUnit; import org.apache.commons.io.FileUtils; @@ -174,7 +171,7 @@ public class ProcessManager { private String[] buildJavaCommand(int vmNum, int namingPort, String version) { String cmd = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; - String dunitClasspath = getClasspath(); + String dunitClasspath = System.getProperty("java.class.path"); String classPath; if (!VersionManager.isCurrentVersion(version)) { classPath = versionManager.getClasspath(version) + File.pathSeparator + dunitClasspath; @@ -236,21 +233,6 @@ public class ProcessManager { return rst; } - private String getClasspath() { - String classpath = System.getProperty("java.class.path"); - // Workaround for GEODE-2386 - long endTime = System.nanoTime() + TimeUnit.SECONDS.toNanos(30); - while (classpath.contains("gradle-worker.jar") && System.nanoTime() < endTime) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - // do nothing - } - classpath = System.getProperty("java.class.path"); - } - return classpath; - } - private String removeJREJars(String classpath) { String[] jars = classpath.split(File.pathSeparator); StringBuilder sb = new StringBuilder(classpath.length());
