You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2012/09/18 10:16:50 UTC
svn commit: r1387041 - in /jackrabbit/trunk/jackrabbit-core/src:
main/java/org/apache/jackrabbit/core/observation/
test/java/org/apache/jackrabbit/core/observation/
Author: mreutegg
Date: Tue Sep 18 08:16:50 2012
New Revision: 1387041
URL: http://svn.apache.org/viewvc?rev=1387041&view=rev
Log:
JCR-3426: Log warning when changes are performed with event notification thread
Added:
jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/WarningOnSaveWithNotificationThreadTest.java (with props)
Modified:
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java
jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/TestAll.java
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java?rev=1387041&r1=1387040&r2=1387041&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java Tue Sep 18 08:16:50 2012
@@ -205,6 +205,16 @@ public final class ObservationDispatcher
* registered {@link javax.jcr.observation.EventListener}s.
*/
void dispatchEvents(EventStateCollection events) {
+ // JCR-3426: log warning when changes are done
+ // with the notification thread
+ if (Thread.currentThread() == notificationThread) {
+ log.warn("Save call with event notification thread detected. This " +
+ "may lead to a growing event queue. Enable debug log to " +
+ "see the stack trace with the class calling save().");
+ if (log.isDebugEnabled()) {
+ log.debug("Stack trace:", new Exception());
+ }
+ }
// notify synchronous listeners
Set<EventConsumer> synchronous = getSynchronousConsumers();
if (log.isDebugEnabled()) {
Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/TestAll.java?rev=1387041&r1=1387040&r2=1387041&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/TestAll.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/TestAll.java Tue Sep 18 08:16:50 2012
@@ -41,6 +41,7 @@ public class TestAll extends TestCase {
suite.addTestSuite(VersionEventsTest.class);
suite.addTestSuite(MoveInPlaceTest.class);
suite.addTestSuite(ShareableNodesTest.class);
+ suite.addTestSuite(WarningOnSaveWithNotificationThreadTest.class);
return suite;
}
Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/WarningOnSaveWithNotificationThreadTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/WarningOnSaveWithNotificationThreadTest.java?rev=1387041&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/WarningOnSaveWithNotificationThreadTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/WarningOnSaveWithNotificationThreadTest.java Tue Sep 18 08:16:50 2012
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.observation;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.observation.EventIterator;
+import javax.jcr.observation.EventListener;
+
+import org.apache.jackrabbit.core.Tail;
+import org.apache.jackrabbit.test.api.observation.AbstractObservationTest;
+import org.apache.jackrabbit.test.api.observation.EventResult;
+
+/**
+ * <code>WarningOnSaveWithNotificationThreadTest</code> checks if the repository
+ * writes a warning to the log file when changes are performed with the event
+ * notification thread. See JCR-3426.
+ */
+public class WarningOnSaveWithNotificationThreadTest extends
+ AbstractObservationTest {
+
+ private static final String MESSAGE = "Save call with event notification thread detected";
+
+ public void testWarning() throws Exception {
+ final List<Exception> exceptions = new ArrayList<Exception>();
+ EventResult result = new EventResult(log) {
+ @Override
+ public void onEvent(EventIterator events) {
+ try {
+ Session s = getHelper().getSuperuserSession();
+ try {
+ s.getNode(testRoot).addNode("bar");
+ s.save();
+ } finally {
+ s.logout();
+ }
+ } catch (RepositoryException e) {
+ exceptions.add(e);
+ }
+ super.onEvent(events);
+ }
+ };
+ addEventListener(result);
+
+ Tail tail = Tail.start(new File("target", "jcr.log"), MESSAGE);
+ try {
+ testRootNode.addNode("foo");
+ superuser.save();
+
+ removeEventListener(result);
+ result.getEvents(5000);
+ assertTrue("Warn message expected in log file.",
+ tail.getLines().iterator().hasNext());
+ } finally {
+ tail.close();
+ }
+
+ if (!exceptions.isEmpty()) {
+ fail(exceptions.get(0).toString());
+ }
+ }
+}
Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/WarningOnSaveWithNotificationThreadTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/observation/WarningOnSaveWithNotificationThreadTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL