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);