From bfb13452bae8e35fac9a79aa6974ded72769dd13 Mon Sep 17 00:00:00 2001 From: Daniel Barclay Date: Mon, 12 Feb 2018 16:09:39 -0500 Subject: [PATCH] Fixed bug in computing pathname of copied .yaml file --- .../utils/EmbeddedCassandraServerHelper.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cassandra-unit/src/main/java/org/cassandraunit/utils/EmbeddedCassandraServerHelper.java b/cassandra-unit/src/main/java/org/cassandraunit/utils/EmbeddedCassandraServerHelper.java index f6055423..1f28536e 100644 --- a/cassandra-unit/src/main/java/org/cassandraunit/utils/EmbeddedCassandraServerHelper.java +++ b/cassandra-unit/src/main/java/org/cassandraunit/utils/EmbeddedCassandraServerHelper.java @@ -17,6 +17,7 @@ import java.io.*; import java.net.ServerSocket; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; @@ -96,8 +97,7 @@ public static void startEmbeddedCassandra(String yamlFile, String tmpDir, long t } rmdir(tmpDir); - copy(yamlFile, tmpDir); - File file = new File(tmpDir + yamlFile); + File file = copy(yamlFile, tmpDir).toFile(); readAndAdaptYaml(file); startEmbeddedCassandra(file, tmpDir, timeout); } @@ -286,11 +286,13 @@ private static void rmdir(String dir) { * @param directory * @throws IOException */ - private static void copy(String resource, String directory) throws IOException { + private static Path copy(String resource, String directory) throws IOException { mkdir(directory); String fileName = resource.substring(resource.lastIndexOf("/") + 1); InputStream from = EmbeddedCassandraServerHelper.class.getResourceAsStream(resource); - Files.copy(from, Paths.get(directory + System.getProperty("file.separator") + fileName)); + Path copyName = Paths.get(directory, fileName); + Files.copy(from, copyName); + return copyName; } /**