You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by tr...@apache.org on 2014/04/05 01:32:44 UTC

svn commit: r1584937 - in /jackrabbit/oak/trunk: oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/ oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/

Author: tripod
Date: Fri Apr  4 23:32:44 2014
New Revision: 1584937

URL: http://svn.apache.org/r1584937
Log:
OAK-1679 LdapLoginTestBase#testConcurrentLoginSameGroup fails if conflict handling is enabled

fixed by retrying user synchronization a couple of times.

Modified:
    jackrabbit/oak/trunk/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/ExternalLoginModule.java
    jackrabbit/oak/trunk/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/LdapLoginTestBase.java

Modified: jackrabbit/oak/trunk/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/ExternalLoginModule.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/ExternalLoginModule.java?rev=1584937&r1=1584936&r2=1584937&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/ExternalLoginModule.java (original)
+++ jackrabbit/oak/trunk/oak-auth-external/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/impl/ExternalLoginModule.java Fri Apr  4 23:32:44 2014
@@ -59,6 +59,9 @@ public class ExternalLoginModule extends
 
     private static final Logger log = LoggerFactory.getLogger(ExternalLoginModule.class);
 
+    // todo: make configurable
+    private static final int MAX_SYNC_ATTEMPTS = 50;
+
     /**
      * Name of the parameter that configures the name of the external identity provider.
      */
@@ -283,32 +286,39 @@ public class ExternalLoginModule extends
      * @throws SyncException if an error occurs
      */
     private void syncUser(@Nonnull ExternalUser user) throws SyncException {
-        SyncContext context = null;
-        try {
-            Root root = getRoot();
-            if (root == null) {
-                throw new SyncException("Cannot synchronize user. root == null");
-            }
-            UserManager userManager = getUserManager();
-            if (userManager == null) {
-                throw new SyncException("Cannot synchronize user. userManager == null");
-            }
-            DebugTimer timer = new DebugTimer();
-            context = syncHandler.createContext(idp, userManager, root);
-            context.sync(user);
-            timer.mark("sync");
-            root.commit();
-            timer.mark("commit");
-            if (log.isDebugEnabled()) {
-                log.debug("syncUser({}) {}", user.getId(), timer.getString());
-            }
-        } catch (CommitFailedException e) {
-            throw new SyncException("User synchronization failed during commit.", e);
-        } finally {
-            if (context != null) {
-                context.close();
+        Root root = getRoot();
+        if (root == null) {
+            throw new SyncException("Cannot synchronize user. root == null");
+        }
+        UserManager userManager = getUserManager();
+        if (userManager == null) {
+            throw new SyncException("Cannot synchronize user. userManager == null");
+        }
+
+        int numAttempt = 0;
+        while (numAttempt++ < MAX_SYNC_ATTEMPTS) {
+            SyncContext context = null;
+            try {
+                DebugTimer timer = new DebugTimer();
+                context = syncHandler.createContext(idp, userManager, root);
+                context.sync(user);
+                timer.mark("sync");
+                root.commit();
+                timer.mark("commit");
+                if (log.isDebugEnabled()) {
+                    log.debug("syncUser({}) {}", user.getId(), timer.getString());
+                }
+                return;
+            } catch (CommitFailedException e) {
+                log.warn("User synchronization failed during commit: {}. (attempt {}/{})", e.toString(), numAttempt, MAX_SYNC_ATTEMPTS);
+                root.refresh();
+            } finally {
+                if (context != null) {
+                    context.close();
+                }
             }
         }
+        throw new SyncException("User synchronization failed during commit after " + MAX_SYNC_ATTEMPTS + " attempts");
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/LdapLoginTestBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/LdapLoginTestBase.java?rev=1584937&r1=1584936&r2=1584937&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/LdapLoginTestBase.java (original)
+++ jackrabbit/oak/trunk/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/LdapLoginTestBase.java Fri Apr  4 23:32:44 2014
@@ -337,7 +337,6 @@ public abstract class LdapLoginTestBase 
         concurrentLogin(CONCURRENT_TEST_USERS);
     }
 
-    @Ignore("OAK-1679") // FIXME OAK-1679
     @Test
     public void testConcurrentLoginSameGroup() throws Exception {
         concurrentLogin(CONCURRENT_GROUP_TEST_USERS);