From 3464197249e9a9f3ac16f6f68886bb9016612956 Mon Sep 17 00:00:00 2001 From: Varun Thacker Date: Fri, 10 Apr 2015 11:52:43 +0000 Subject: [PATCH] SOLR-6637: can't assume a local filesystem when dealing with paths git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1672620 13f79535-47bb-0310-9956-ffa450edef68 --- .../core/src/java/org/apache/solr/handler/IndexFetcher.java | 2 +- solr/core/src/java/org/apache/solr/handler/RestoreCore.java | 6 +++--- .../org/apache/solr/handler/TestReplicationHandler.java | 2 +- .../src/test/org/apache/solr/handler/TestRestoreCore.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java index 1983282ea89..1b7b17981b0 100644 --- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java +++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java @@ -356,7 +356,7 @@ public class IndexFetcher { || commit.getGeneration() >= latestGeneration || forceReplication; String tmpIdxDirName = "index." + new SimpleDateFormat(SnapShooter.DATE_FMT, Locale.ROOT).format(new Date()); - tmpIndex = Paths.get(solrCore.getDataDir(), tmpIdxDirName).toString(); + tmpIndex = solrCore.getDataDir() + tmpIdxDirName; tmpIndexDir = solrCore.getDirectoryFactory().get(tmpIndex, DirContext.DEFAULT, solrCore.getSolrConfig().indexConfig.lockType); diff --git a/solr/core/src/java/org/apache/solr/handler/RestoreCore.java b/solr/core/src/java/org/apache/solr/handler/RestoreCore.java index 37d7172d28c..0a09f0b8833 100644 --- a/solr/core/src/java/org/apache/solr/handler/RestoreCore.java +++ b/solr/core/src/java/org/apache/solr/handler/RestoreCore.java @@ -55,15 +55,15 @@ public class RestoreCore implements Callable { private boolean doRestore() throws Exception { - Path backupPath = Paths.get(backupLocation, backupName); + Path backupPath = Paths.get(backupLocation).resolve(backupName); String restoreIndexName = "restore." + backupName; - Path restoreIndexPath = Paths.get(core.getDataDir(), restoreIndexName); + String restoreIndexPath = core.getDataDir() + restoreIndexName; Directory restoreIndexDir = null; Directory indexDir = null; try (Directory backupDir = FSDirectory.open(backupPath)) { - restoreIndexDir = core.getDirectoryFactory().get(restoreIndexPath.toString(), + restoreIndexDir = core.getDirectoryFactory().get(restoreIndexPath, DirectoryFactory.DirContext.DEFAULT, core.getSolrConfig().indexConfig.lockType); //Prefer local copy. diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java index feed24acbe1..6ebefde4c58 100644 --- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java +++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java @@ -1274,7 +1274,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 { masterClient.close(); masterJetty.stop(); - Directory dir = FSDirectory.open(Paths.get(dataDir, "index")); + Directory dir = FSDirectory.open(Paths.get(dataDir).resolve("index")); String[] files = dir.listAll(); long totalBytes = 0; for(String file : files) { diff --git a/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java b/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java index 20f3afdb042..00eb43f789f 100644 --- a/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java +++ b/solr/core/src/test/org/apache/solr/handler/TestRestoreCore.java @@ -186,7 +186,7 @@ public class TestRestoreCore extends SolrJettyTestBase { //Remove the segments_n file so that the backup index is corrupted. //Restore should fail and it should automatically rollback to the original index. - Path restoreIndexPath = Paths.get(location, "snapshot." + snapshotName); + Path restoreIndexPath = Paths.get(location).resolve("snapshot." + snapshotName); try (DirectoryStream stream = Files.newDirectoryStream(restoreIndexPath, IndexFileNames.SEGMENTS + "*")) { Path segmentFileName = stream.iterator().next(); Files.delete(segmentFileName);