Index: ../oak/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../oak/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java	(revision 1585664)
+++ ../oak/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java	(revision )
@@ -29,6 +29,7 @@
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.UUID;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.jcr.AccessDeniedException;
@@ -210,11 +211,7 @@
         if (tokenParent != null) {
             try {
                 long creationTime = new Date().getTime();
-                Calendar creation = GregorianCalendar.getInstance();
-                creation.setTimeInMillis(creationTime);
-                String tokenName = Text.replace(ISO8601.format(creation), ":", ".");
-
-                NodeUtil tokenNode = tokenParent.addChild(tokenName, TOKEN_NT_NAME);
+                NodeUtil tokenNode = createTokenNode(tokenParent, creationTime);
                 tokenNode.setString(JcrConstants.JCR_UUID, IdentifierManager.generateUUID());
 
                 String key = generateKey(options.getConfigValue(PARAM_TOKEN_LENGTH, DEFAULT_KEY_SIZE));
@@ -395,6 +392,31 @@
             }
         }
         return tokenParent;
+    }
+
+    /**
+     * Create a new token node below the specified {@code parent}.
+     *
+     * @param parent The parent node.
+     * @param creationTime The creation time that is used as name hint.
+     * @return The new token node
+     * @throws AccessDeniedException
+     */
+    private NodeUtil createTokenNode(@Nonnull NodeUtil parent, @Nonnull long creationTime) throws AccessDeniedException {
+        Calendar creation = GregorianCalendar.getInstance();
+        creation.setTimeInMillis(creationTime);
+        String tokenName = Text.replace(ISO8601.format(creation), ":", ".");
+        NodeUtil tokenNode;
+        try {
+            tokenNode = parent.addChild(tokenName, TOKEN_NT_NAME);
+            root.commit();
+        } catch (CommitFailedException e) {
+            // conflict while creating token node -> retry
+            log.debug("Failed to create token node " + tokenName + ". Using random name as fallback.");
+            root.refresh();
+            tokenNode = parent.addChild(UUID.randomUUID().toString(), TOKEN_NT_NAME);
+        }
+        return tokenNode;
     }
 
     //--------------------------------------------------------------------------
