jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1492561 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.java
Date Thu, 13 Jun 2013 08:23:02 GMT
Author: mduerig
Date: Thu Jun 13 08:23:02 2013
New Revision: 1492561

URL: http://svn.apache.org/r1492561
Log:
OAK-144 Implement Observation
log stack trace from where an offending listener was registered

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeProcessor.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=1492561&r1=1492560&r2=1492561&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 Jun 13 08:23:02 2013
@@ -18,6 +18,8 @@
  */
 package org.apache.jackrabbit.oak.plugins.observation;
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -60,6 +62,8 @@ class ChangeProcessor implements Runnabl
     private final AtomicReference<EventFilter> filterRef;
     private final AtomicReference<String> userDataRef = new AtomicReference<String>(null);
 
+    private final String initStacktrace;
+
     private volatile boolean running;
     private volatile boolean stopping;
     private ScheduledFuture<?> future;
@@ -75,6 +79,14 @@ class ChangeProcessor implements Runnabl
         this.namePathMapper = observationManager.getNamePathMapper();
         this.listener = listener;
         filterRef = new AtomicReference<EventFilter>(filter);
+        initStacktrace = log.isWarnEnabled(DEPRECATED) ? getStackTrace() : null;
+    }
+
+    private static String getStackTrace() {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        new Exception().printStackTrace(pw);
+        return sw.toString();
     }
 
     public void setFilter(EventFilter filter) {
@@ -152,8 +164,9 @@ class ChangeProcessor implements Runnabl
         if (!userInfoAccessedWithoutExternalsCheck) {
             log.warn(DEPRECATED,
                     "Event listener " + listener + " is trying to access"
-                    + " event user information without checking for whether"
-                    + " the event is external on " + event);
+                    + " event user information on event " + event
+                    + " without checking whether the event is external."
+                    + " The event listener was registered here: " + initStacktrace);
             userInfoAccessedWithoutExternalsCheck = true;
         }
     }
@@ -162,7 +175,8 @@ class ChangeProcessor implements Runnabl
         if (!userInfoAccessedFromExternalEvent) {
             log.warn(DEPRECATED,
                     "Event listener " + listener + " is trying to access"
-                    + " event user information from an external event on " + event);
+                    + " event user information for external event " + event + '.'
+                    + " The event listener was registered here: " + initStacktrace);
             userInfoAccessedFromExternalEvent = true;
         }
     }
@@ -171,8 +185,9 @@ class ChangeProcessor implements Runnabl
         if (!dateAccessedWithoutExternalsCheck) {
             log.warn(DEPRECATED,
                     "Event listener " + listener + " is trying to access"
-                    + " event date information without checking for whether"
-                    + " the event is external on " + event);
+                    + " event date information on event " + event
+                    + " without checking whether the event is external."
+                    + " The event listener was registered here: " + initStacktrace);
             dateAccessedWithoutExternalsCheck = true;
         }
     }
@@ -181,7 +196,8 @@ class ChangeProcessor implements Runnabl
         if (!dateAccessedFromExternalEvent) {
             log.warn(DEPRECATED,
                     "Event listener " + listener + " is trying to access"
-                    + " event date information from an external event on " + event);
+                    + " event date information for external event " + event + '.'
+                    + " The event listener was registered here: " + initStacktrace);
             dateAccessedFromExternalEvent = true;
         }
     }



Mime
View raw message