From d59162c49f96da1e990fe9982d1afa08d25c00b1 Mon Sep 17 00:00:00 2001 From: Morten Tokle Date: Fri, 22 Nov 2019 15:45:43 +0100 Subject: Use filesystem when resolving paths --- .../src/main/java/com/yahoo/vespa/athenz/utils/SiaUtils.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'vespa-athenz/src') diff --git a/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/utils/SiaUtils.java b/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/utils/SiaUtils.java index 4d7f4b1c397..12a8c3f911e 100644 --- a/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/utils/SiaUtils.java +++ b/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/utils/SiaUtils.java @@ -97,7 +97,7 @@ public class SiaUtils { Files.createDirectories(privateKeyFile.getParent()); Path tempFile = toTempFile(privateKeyFile); Files.write(tempFile, KeyUtils.toPem(privateKey).getBytes()); - Files.move(tempFile, privateKeyFile, StandardCopyOption.ATOMIC_MOVE); + Files.move(tempFile, privateKeyFile, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { throw new UncheckedIOException(e); } @@ -113,7 +113,7 @@ public class SiaUtils { Files.createDirectories(certificateFile.getParent()); Path tempFile = toTempFile(certificateFile); Files.write(tempFile, X509CertificateUtils.toPem(certificate).getBytes()); - Files.move(tempFile, certificateFile, StandardCopyOption.ATOMIC_MOVE); + Files.move(tempFile, certificateFile, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { throw new UncheckedIOException(e); } @@ -142,7 +142,6 @@ public class SiaUtils { } private static Path toTempFile(Path file) { - return Paths.get(file.toAbsolutePath().toString() + ".tmp"); + return file.getParent().resolve(file.getFileName().toString() + ".tmp"); } - } -- cgit v1.2.3