You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bs...@apache.org on 2018/01/08 20:10:41 UTC

[geode] branch feature/GEODE-4180 created (now dc1ae9c)

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

bschuchardt pushed a change to branch feature/GEODE-4180
in repository https://gitbox.apache.org/repos/asf/geode.git.


      at dc1ae9c  GEODE-4180 always use absolute paths

This branch includes the following new commits:

     new dc1ae9c  GEODE-4180 always use absolute paths

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].

[geode] 01/01: GEODE-4180 always use absolute paths

Posted by bs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bschuchardt pushed a commit to branch feature/GEODE-4180
in repository https://gitbox.apache.org/repos/asf/geode.git

commit dc1ae9cde903d75da990b6ff3c299097bde060c9
Author: Bruce Schuchardt <bs...@pivotal.io>
AuthorDate: Mon Jan 8 11:43:32 2018 -0800

    GEODE-4180 always use absolute paths
    
    Modified the locator to use absolute paths for the persistent view file
    and for the product use log.
    
    There is no unit test for ProductUseLog because it doesn't try to read its file.  It just writes to a new file.
---
 .../geode/distributed/internal/ProductUseLog.java  |  3 ++-
 .../membership/gms/locator/GMSLocator.java         |  9 ++++++---
 .../gms/locator/GMSLocatorRecoveryJUnitTest.java   | 23 ++++++++++++++++++++++
 3 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/ProductUseLog.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/ProductUseLog.java
index 1e99b86..dd4a633 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/ProductUseLog.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/ProductUseLog.java
@@ -53,7 +53,8 @@ public class ProductUseLog implements MembershipListener {
   }
 
   public ProductUseLog(File productUseLogFile) {
-    this.productUseLogFile = productUseLogFile;
+    // GEODE-4180, use absolute paths
+    this.productUseLogFile = new File(productUseLogFile.getAbsolutePath());
     this.logLevel = InternalLogWriter.INFO_LEVEL;
     createLogWriter();
   }
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java
index cecc4a9..85570bd 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocator.java
@@ -137,14 +137,17 @@ public class GMSLocator implements Locator, NetLocator {
   /**
    * Test hook - set the persistent view file
    */
-  public void setViewFile(File file) {
-    this.viewFile = file;
+  public File setViewFile(File file) {
+    this.viewFile = new File(file.getAbsolutePath()); // GEODE-4180, use absolute paths
+    return this.viewFile;
   }
 
   @Override
   public void init(TcpServer server) throws InternalGemFireException {
     if (this.viewFile == null) {
-      this.viewFile = new File("locator" + server.getPort() + "view.dat");
+      // GEODE-4180, use absolute paths
+      this.viewFile =
+          new File(new File("locator" + server.getPort() + "view.dat").getAbsolutePath());
     }
     logger.info(
         "GemFire peer location service starting.  Other locators: {}  Locators preferred as coordinators: {}  Network partition detection enabled: {}  View persistence file: {}",
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
index 7906534..f13cbca 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
@@ -193,4 +193,27 @@ public class GMSLocatorRecoveryJUnitTest {
       }
     }
   }
+
+  @Test
+  public void testViewFileFoundWhenUserDirModified() throws Exception {
+    NetView view = new NetView();
+    populateStateFile(this.tempStateFile, GMSLocator.LOCATOR_FILE_STAMP, Version.CURRENT_ORDINAL,
+        view);
+
+    String userDir = System.getProperty("user.dir");
+    try {
+      File dir = new File("testViewFileFoundWhenUserDirModified");
+      dir.mkdir();
+      System.setProperty("user.dir", dir.getAbsolutePath());
+      File viewFileInNewDirectory = new File(tempStateFile.getName());
+      // GEODE-4180 - file in parent dir still seen with relative path
+      assertTrue(viewFileInNewDirectory.exists());
+      File locatorViewFile = locator.setViewFile(viewFileInNewDirectory);
+      assertFalse(locator.recoverFromFile(locatorViewFile));
+    } finally {
+      System.setProperty("user.dir", userDir);
+    }
+  }
+
+
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@geode.apache.org" <co...@geode.apache.org>.