jackrabbit-oak-commits mailing list archives

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

URL: http://svn.apache.org/r1492631
Log:
OAK-144 Implement Observation
log stack trace from where an offending listener was registered: let logger take care of formatting
the stack trace

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=1492631&r1=1492630&r2=1492631&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 11:43:23 2013
@@ -18,8 +18,6 @@
  */
 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;
@@ -62,7 +60,7 @@ class ChangeProcessor implements Runnabl
     private final AtomicReference<EventFilter> filterRef;
     private final AtomicReference<String> userDataRef = new AtomicReference<String>(null);
 
-    private final String initStacktrace;
+    private final Exception initStacktrace;
 
     private volatile boolean running;
     private volatile boolean stopping;
@@ -79,14 +77,7 @@ 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();
+        initStacktrace = log.isWarnEnabled(DEPRECATED) ? new Exception("Initialized here")
: null;
     }
 
     public void setFilter(EventFilter filter) {
@@ -166,7 +157,7 @@ class ChangeProcessor implements Runnabl
                     "Event listener " + listener + " is trying to access"
                     + " event user information on event " + event
                     + " without checking whether the event is external."
-                    + " The event listener was registered here: " + initStacktrace);
+                    + " The event listener was registered here: ",  initStacktrace);
             userInfoAccessedWithoutExternalsCheck = true;
         }
     }
@@ -176,7 +167,7 @@ class ChangeProcessor implements Runnabl
             log.warn(DEPRECATED,
                     "Event listener " + listener + " is trying to access"
                     + " event user information for external event " + event + '.'
-                    + " The event listener was registered here: " + initStacktrace);
+                    + " The event listener was registered here: ", initStacktrace);
             userInfoAccessedFromExternalEvent = true;
         }
     }
@@ -187,7 +178,7 @@ class ChangeProcessor implements Runnabl
                     "Event listener " + listener + " is trying to access"
                     + " event date information on event " + event
                     + " without checking whether the event is external."
-                    + " The event listener was registered here: " + initStacktrace);
+                    + " The event listener was registered here: ", initStacktrace);
             dateAccessedWithoutExternalsCheck = true;
         }
     }
@@ -197,7 +188,7 @@ class ChangeProcessor implements Runnabl
             log.warn(DEPRECATED,
                     "Event listener " + listener + " is trying to access"
                     + " event date information for external event " + event + '.'
-                    + " The event listener was registered here: " + initStacktrace);
+                    + " The event listener was registered here: ", initStacktrace);
             dateAccessedFromExternalEvent = true;
         }
     }



Mime
View raw message