You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2018/06/20 13:48:37 UTC

[geode] branch develop updated: GEODE-5330: only create one temp folder (#2068)

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

jensdeppe 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 f5eab20  GEODE-5330: only create one temp folder (#2068)
f5eab20 is described below

commit f5eab203dbaeaf383eef2bfa5f3d51468269579a
Author: Helena Bales <hb...@pivotal.io>
AuthorDate: Wed Jun 20 06:48:32 2018 -0700

    GEODE-5330: only create one temp folder (#2068)
    
    One temp folder will be left after tests complete. This was the behavior
    that GfshCommandRule had prior to GEODE-5327. It is caused by the
    creation of the temp directory in the constructor of GfshCommandRule. If
    the creation happened only in before(), only one temp directory would be
    created and cleaned up. However, this would cause some existing DUnit
    tests to break, as they use the GfshCommandRule in a way that never
    calls before().
    
    The creation of the temp folder was added to before() as part of
    GEODE-5327 so that IntelliJ could run DUnit tests multiple times.
---
 .../geode/test/junit/rules/GfshCommandRule.java    | 38 +++++++++++++++-------
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/geode-core/src/test/java/org/apache/geode/test/junit/rules/GfshCommandRule.java b/geode-core/src/test/java/org/apache/geode/test/junit/rules/GfshCommandRule.java
index 12cb989..8a03309f04 100644
--- a/geode-core/src/test/java/org/apache/geode/test/junit/rules/GfshCommandRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/junit/rules/GfshCommandRule.java
@@ -96,7 +96,11 @@ public class GfshCommandRule extends DescribedExternalResource {
   protected void before(Description description) throws Throwable {
     LogWrapper.close();
     createTempFolder();
-    workingDir = temporaryFolder.newFolder("gfsh_files");
+    try {
+      workingDir = temporaryFolder.newFolder("gfsh_files");
+    } catch (IOException e) {
+      workingDir = temporaryFolder.getRoot();
+    }
     this.gfsh = new HeadlessGfsh(getClass().getName(), gfshTimeout, workingDir.getAbsolutePath());
     ignoredException =
         addIgnoredException("java.rmi.NoSuchObjectException: no such object in table");
@@ -116,14 +120,6 @@ public class GfshCommandRule extends DescribedExternalResource {
     }
   }
 
-  private void createTempFolder() {
-    try {
-      temporaryFolder.create();
-    } catch (IOException e) {
-      throw new UncheckedIOException(e);
-    }
-  }
-
   @Override
   protected void after(Description description) throws Throwable {
     close();
@@ -133,6 +129,20 @@ public class GfshCommandRule extends DescribedExternalResource {
     }
   }
 
+  private void createTempFolder() {
+    // check if the temp folder exists and create it if needed
+    // an IllegalStateException will be thrown if the temp folder does not exist
+    try {
+      temporaryFolder.getRoot();
+    } catch (IllegalStateException e) {
+      try {
+        temporaryFolder.create();
+      } catch (IOException ioe) {
+        throw new UncheckedIOException(ioe);
+      }
+    }
+  }
+
   public void connect(Member locator, String... options) throws Exception {
     connect(locator.getPort(), PortType.locator, options);
   }
@@ -162,8 +172,14 @@ public class GfshCommandRule extends DescribedExternalResource {
 
   public void connect(int port, PortType type, String... options) throws Exception {
     if (gfsh == null) {
-      this.gfsh = new HeadlessGfsh(getClass().getName(), 30,
-          temporaryFolder.newFolder("gfsh_files").getAbsolutePath());
+      String absolutePath;
+      try {
+        absolutePath = temporaryFolder.newFolder("gfsh_files").getAbsolutePath();
+      } catch (IOException e) {
+        absolutePath = temporaryFolder.getRoot().getAbsolutePath();
+      }
+
+      this.gfsh = new HeadlessGfsh(getClass().getName(), 30, absolutePath);
     }
     final CommandStringBuilder connectCommand = new CommandStringBuilder(CliStrings.CONNECT);
     String endpoint;