jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1466790 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: plugins/observation/ChangeProcessor.java util/TODO.java
Date Thu, 11 Apr 2013 08:24:18 GMT
Author: jukka
Date: Thu Apr 11 08:24:18 2013
New Revision: 1466790

URL: http://svn.apache.org/r1466790
Log:
OAK-675: Observation generates NPE in an existing EventListener

Use the TODO mechanism to return a dummy non-null value for now.

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/TODO.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.java?rev=1466790&r1=1466789&r2=1466790&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.java
Thu Apr 11 08:24:18 2013
@@ -39,6 +39,7 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
+import org.apache.jackrabbit.oak.util.TODO;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -242,7 +243,8 @@ class ChangeProcessor implements Runnabl
             String jcrPath = namePathMapper.getJcrPath(PathUtils.concat(parentPath, property.getName()));
 
             // TODO support userId, identifier, info, date
-            return new EventImpl(eventType, jcrPath, null, null, null, 0);
+            String userId = TODO.dummyImplementation().returnValueOrNull("oak:unknown");
+            return new EventImpl(eventType, jcrPath, userId, null, null, 0);
         }
 
         private Iterator<Event> generateNodeEvents(int eventType, String parentPath,
String name, NodeState node) {
@@ -254,7 +256,8 @@ class ChangeProcessor implements Runnabl
             Iterator<Event> nodeEvent;
             if (filter.include(eventType, jcrParentPath, associatedParentNode)) {
                 // TODO support userId, identifier, info, date
-                Event event = new EventImpl(eventType, jcrPath, null, null, null, 0);
+                String userId = TODO.dummyImplementation().returnValueOrNull("oak:unknown");
+                Event event = new EventImpl(eventType, jcrPath, userId, null, null, 0);
                 nodeEvent = Iterators.singletonIterator(event);
             } else {
                 nodeEvent = Iterators.emptyIterator();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/TODO.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/TODO.java?rev=1466790&r1=1466789&r2=1466790&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/TODO.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/TODO.java Thu
Apr 11 08:24:18 2013
@@ -71,6 +71,17 @@ public class TODO {
         }
     }
 
+    public <T> T returnValueOrNull(T value) {
+        if (strict) {
+            return null;
+        } else {
+            if (log) {
+                logger.warn(message, exception);
+            }
+            return value;
+        }
+    }
+
     public void doNothing() throws UnsupportedRepositoryOperationException {
         if (strict) {
             throw exception();



Mime
View raw message