فهرست منبع

ZOOKEEPER-734. QuorumPeerTestBase.java and ZooKeeperServerMainTest.java do not handle windows path correctly

git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/trunk@938212 13f79535-47bb-0310-9956-ffa450edef68
Patrick D. Hunt 15 سال پیش
والد
کامیت
7ecd589c15

+ 3 - 0
CHANGES.txt

@@ -29,6 +29,9 @@ BUGFIXES:
   ZOOKEEPER-738. zookeeper.jute.h fails to compile with -pedantic
   (Jozef Hatala via phunt)
 
+  ZOOKEEPER-734. QuorumPeerTestBase.java and ZooKeeperServerMainTest.java
+  do not handle windows path correctly (Vishal K via phunt)
+
 IMPROVEMENTS:
   ZOOKEEPER-724. Improve junit test integration - log harness information 
   (phunt via mahadev)

+ 9 - 2
src/java/test/org/apache/zookeeper/server/ZooKeeperServerMainTest.java

@@ -61,8 +61,15 @@ public class ZooKeeperServerMainTest extends ZKTestCase implements Watcher {
             if (!dataDir.mkdir()) {
                 throw new IOException("unable to mkdir " + dataDir);
             }
-            fwriter.write("dataDir=" + dataDir.toString() + "\n");
-
+            
+            // Convert windows path to UNIX to avoid problems with "\"
+            String dir = dataDir.toString();
+            String osname = java.lang.System.getProperty("os.name");
+            if (osname.toLowerCase().contains("windows")) {
+                dir = dir.replace('\\', '/');
+            }
+            fwriter.write("dataDir=" + dir + "\n");
+            
             fwriter.write("clientPort=" + clientPort + "\n");
             fwriter.flush();
             fwriter.close();

+ 8 - 1
src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerTestBase.java

@@ -72,8 +72,15 @@ public class QuorumPeerTestBase extends ZKTestCase implements Watcher {
             if (!dataDir.mkdir()) {
                 throw new IOException("Unable to mkdir " + dataDir);
             }
-            fwriter.write("dataDir=" + dataDir.toString() + "\n");
 
+            // Convert windows path to UNIX to avoid problems with "\"
+            String dir = dataDir.toString();
+            String osname = java.lang.System.getProperty("os.name");
+            if (osname.toLowerCase().contains("windows")) {
+                dir = dir.replace('\\', '/');
+            }
+            fwriter.write("dataDir=" + dir + "\n");
+            
             fwriter.write("clientPort=" + clientPort + "\n");
             fwriter.write(quorumCfgSection + "\n");
             fwriter.flush();