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 al...@apache.org on 2016/12/05 14:45:52 UTC

svn commit: r1772684 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java

Author: alexparvulescu
Date: Mon Dec  5 14:45:52 2016
New Revision: 1772684

URL: http://svn.apache.org/viewvc?rev=1772684&view=rev
Log:
OAK-5216 AsyncIndexUpdate: CONCURRENT_UPDATE should contain relevant stacktrace


Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java?rev=1772684&r1=1772683&r2=1772684&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java Mon Dec  5 14:45:52 2016
@@ -110,9 +110,6 @@ public class AsyncIndexUpdate implements
 
     private static final long DEFAULT_LIFETIME = TimeUnit.DAYS.toMillis(1000);
 
-    private static final CommitFailedException CONCURRENT_UPDATE = new CommitFailedException(
-            "Async", 1, "Concurrent update detected");
-
     private static final CommitFailedException INTERRUPTED = new CommitFailedException(
             "Async", 1, "Indexing stopped forcefully");
 
@@ -284,7 +281,7 @@ public class AsyncIndexUpdate implements
                 this.lease = now + 2 * leaseTimeOut;
                 long beforeLease = async.getLong(leaseName);
                 if (beforeLease > now) {
-                    throw CONCURRENT_UPDATE;
+                    throw newConcurrentUpdateException();
                 }
 
                 NodeBuilder builder = root.builder();
@@ -453,7 +450,7 @@ public class AsyncIndexUpdate implements
                 long leaseExpMsg = (leaseEndTime - currentTime) / 1000;
                 String err = String.format("Another copy of the index update is already running; skipping this update. " +
                         "Time left for lease to expire %d s. Indexing can resume by %tT", leaseExpMsg, leaseEndTime);
-                indexStats.failed(new Exception(err, CONCURRENT_UPDATE));
+                indexStats.failed(new Exception(err, newConcurrentUpdateException()));
                 return;
             }
         }
@@ -772,7 +769,7 @@ public class AsyncIndexUpdate implements
                     (lease == null      || lease == async.getLong(leasify(name)))) {
                     return after;
                 } else {
-                    throw CONCURRENT_UPDATE;
+                    throw newConcurrentUpdateException();
                 }
             }
         };
@@ -789,7 +786,7 @@ public class AsyncIndexUpdate implements
         } catch (CommitFailedException ex) {
             // OAK-2961
             if (ex.isOfType(CommitFailedException.STATE) && ex.getCode() == 1) {
-                throw CONCURRENT_UPDATE;
+                throw newConcurrentUpdateException();
             } else {
                 throw ex;
             }
@@ -1392,4 +1389,7 @@ public class AsyncIndexUpdate implements
         return name;
     }
 
+    private static CommitFailedException newConcurrentUpdateException() {
+        return new CommitFailedException("Async", 1, "Concurrent update detected");
+    }
 }