diff options
author | Morten Tokle <mortent@oath.com> | 2019-11-22 15:45:43 +0100 |
---|---|---|
committer | Morten Tokle <mortent@oath.com> | 2019-11-22 15:45:43 +0100 |
commit | d59162c49f96da1e990fe9982d1afa08d25c00b1 (patch) | |
tree | 84179da2782507c1c34a002531c6413fd43247e5 /vespa-athenz | |
parent | bf04cdc3471570c4cfd1ffa57a66eaad1f4263ae (diff) |
Use filesystem when resolving paths
Diffstat (limited to 'vespa-athenz')
-rw-r--r-- | vespa-athenz/src/main/java/com/yahoo/vespa/athenz/utils/SiaUtils.java | 7 |
1 files changed, 3 insertions, 4 deletions
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"); } - } |