jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1526511 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/util/TimingDocumentStoreWrapper.java
Date Thu, 26 Sep 2013 14:29:49 GMT
Author: mreutegg
Date: Thu Sep 26 14:29:48 2013
New Revision: 1526511

URL: http://svn.apache.org/r1526511
Log:
OAK-1047: TimingDocumentStoreWrapper throws NPE when result is null

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/util/TimingDocumentStoreWrapper.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/util/TimingDocumentStoreWrapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/util/TimingDocumentStoreWrapper.java?rev=1526511&r1=1526510&r2=1526511&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/util/TimingDocumentStoreWrapper.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/util/TimingDocumentStoreWrapper.java
Thu Sep 26 14:29:48 2013
@@ -24,6 +24,7 @@ import java.util.concurrent.atomic.Atomi
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 
 import org.apache.jackrabbit.mk.api.MicroKernelException;
 import org.apache.jackrabbit.oak.plugins.mongomk.Collection;
@@ -80,7 +81,7 @@ public class TimingDocumentStoreWrapper 
         try {
             long start = now();
             T result = base.find(collection, key);
-            updateAndLogTimes("find", start, 0, result.getMemory());
+            updateAndLogTimes("find", start, 0, size(result));
             return result;
         } catch (Exception e) {
             throw convert(e);
@@ -93,7 +94,7 @@ public class TimingDocumentStoreWrapper 
         try {
             long start = now();
             T result = base.find(collection, key, maxCacheAge);
-            updateAndLogTimes("find2", start, 0, result.getMemory());
+            updateAndLogTimes("find2", start, 0, size(result));
             return result;
         } catch (Exception e) {
             throw convert(e);
@@ -158,13 +159,13 @@ public class TimingDocumentStoreWrapper 
     }
 
     @Override
-    @Nonnull
+    @CheckForNull
     public <T extends Document> T createOrUpdate(Collection<T> collection, UpdateOp
update)
             throws MicroKernelException {
         try {
             long start = now();
             T result = base.createOrUpdate(collection, update);
-            updateAndLogTimes("createOrUpdate", start, 0, result.getMemory());
+            updateAndLogTimes("createOrUpdate", start, 0, size(result));
             return result;
         } catch (Exception e) {
             throw convert(e);
@@ -178,7 +179,7 @@ public class TimingDocumentStoreWrapper 
         try {
             long start = now();
             T result = base.findAndUpdate(collection, update);
-            updateAndLogTimes("findAndUpdate", start, 0, result.getMemory());
+            updateAndLogTimes("findAndUpdate", start, 0, size(result));
             return result;
         } catch (Exception e) {
             throw convert(e);
@@ -250,6 +251,14 @@ public class TimingDocumentStoreWrapper 
         }
         return result;
     }
+
+    private static int size(@Nullable Document document) {
+        if (document == null) {
+            return 0;
+        } else {
+            return document.getMemory();
+        }
+    }
     
     private static long now() {
         return System.currentTimeMillis();



Mime
View raw message