You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by en...@apache.org on 2021/06/09 00:19:28 UTC

[sling-org-apache-sling-auth-form] branch master updated: SLING-10472 TokenStore.saveTokens fails on windows

This is an automated email from the ASF dual-hosted git repository.

enorman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-auth-form.git


The following commit(s) were added to refs/heads/master by this push:
     new 38b9dfa  SLING-10472 TokenStore.saveTokens fails on windows
38b9dfa is described below

commit 38b9dfaf57c47b2c9a5d91de30d95a889e8df910
Author: Eric Norman <en...@apache.org>
AuthorDate: Tue Jun 8 17:19:17 2021 -0700

    SLING-10472 TokenStore.saveTokens fails on windows
---
 src/main/java/org/apache/sling/auth/form/impl/TokenStore.java | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/sling/auth/form/impl/TokenStore.java b/src/main/java/org/apache/sling/auth/form/impl/TokenStore.java
index 89298fb..9c81492 100644
--- a/src/main/java/org/apache/sling/auth/form/impl/TokenStore.java
+++ b/src/main/java/org/apache/sling/auth/form/impl/TokenStore.java
@@ -25,6 +25,8 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
 import java.security.InvalidKeyException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
@@ -308,10 +310,12 @@ class TokenStore {
             }
         } catch (IOException e) {
             log.error("Failed to save cookie keys {}", e.getMessage());
-            }
-        if (!tmpTokenFile.renameTo(tokenFile)) {
-            log.error("Failed to rename the temporary token file");
+        }
 
+        try {
+            Files.move(tmpTokenFile.toPath(), tokenFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+        } catch (IOException e) {
+            log.error("Failed to rename the temporary token file", e);
         }
     }