Return-Path: X-Original-To: apmail-jackrabbit-commits-archive@www.apache.org Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A0082DCAA for ; Tue, 28 Aug 2012 07:23:52 +0000 (UTC) Received: (qmail 19616 invoked by uid 500); 28 Aug 2012 07:23:52 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 18668 invoked by uid 500); 28 Aug 2012 07:23:48 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 18630 invoked by uid 99); 28 Aug 2012 07:23:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Aug 2012 07:23:47 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Aug 2012 07:23:43 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 188A02388962; Tue, 28 Aug 2012 07:22:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1378004 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/cluster/ main/java/org/apache/jackrabbit/core/state/ test/java/org/apache/jackrabbit/core/cluster/ test/resources/org/apache/jackrabbit/core/cluster/ Date: Tue, 28 Aug 2012 07:22:58 -0000 To: commits@jackrabbit.apache.org From: mreutegg@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120828072259.188A02388962@eris.apache.org> Author: mreutegg Date: Tue Aug 28 07:22:58 2012 New Revision: 1378004 URL: http://svn.apache.org/viewvc?rev=1378004&view=rev Log: JCR-3417: Failed Journal lock not propagated Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/FailUpdateOnJournalExceptionTest.java (with props) jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestJournal.java (with props) jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository-with-test-journal.xml - copied, changed from r1377607, jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository-h2.xml Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventChannel.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestAll.java Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java?rev=1378004&r1=1378003&r2=1378004&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java Tue Aug 28 07:22:58 2012 @@ -605,7 +605,7 @@ public class ClusterNode implements Runn /** * {@inheritDoc} */ - public void updateCreated(Update update) { + public void updateCreated(Update update) throws ClusterException { if (status != STARTED) { log.info("not started: update create ignored."); return; @@ -614,11 +614,12 @@ public class ClusterNode implements Runn Record record = producer.append(); update.setAttribute(ATTRIBUTE_RECORD, record); } catch (JournalException e) { - String msg = "Unable to create log entry."; - log.error(msg, e); + String msg = "Unable to create log entry: " + e.getMessage(); + throw new ClusterException(msg, e); } catch (Throwable e) { - String msg = "Unexpected error while creating log entry."; - log.error(msg, e); + String msg = "Unexpected error while creating log entry: " + + e.getMessage(); + throw new ClusterException(msg, e); } } Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventChannel.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventChannel.java?rev=1378004&r1=1378003&r2=1378004&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventChannel.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/UpdateEventChannel.java Tue Aug 28 07:22:58 2012 @@ -25,8 +25,9 @@ public interface UpdateEventChannel { * Called when an a update operation has been created. * * @param update update operation + * @throws ClusterException if an error occurs writing to the event channel. */ - void updateCreated(Update update); + void updateCreated(Update update) throws ClusterException; /** * Called when an a update operation has been prepared. Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=1378004&r1=1378003&r2=1378004&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java Tue Aug 28 07:22:58 2012 @@ -27,6 +27,7 @@ import javax.jcr.RepositoryException; import javax.jcr.nodetype.NoSuchNodeTypeException; import org.apache.jackrabbit.core.RepositoryImpl; +import org.apache.jackrabbit.core.cluster.ClusterException; import org.apache.jackrabbit.core.cluster.UpdateEventChannel; import org.apache.jackrabbit.core.id.ItemId; import org.apache.jackrabbit.core.id.NodeId; @@ -567,7 +568,11 @@ public class SharedItemStateManager virtualNodeReferences = new ChangeLog[virtualProviders.length]; // let listener know about change - eventChannel.updateCreated(this); + try { + eventChannel.updateCreated(this); + } catch (ClusterException e) { + throw new ItemStateException(e.getMessage(), e); + } try { writeLock = acquireWriteLock(local); Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/FailUpdateOnJournalExceptionTest.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/FailUpdateOnJournalExceptionTest.java?rev=1378004&view=auto ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/FailUpdateOnJournalExceptionTest.java (added) +++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/FailUpdateOnJournalExceptionTest.java Tue Aug 28 07:22:58 2012 @@ -0,0 +1,86 @@ +/* + * 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.cluster; + +import java.io.File; +import java.io.IOException; + +import javax.jcr.Node; +import javax.jcr.RepositoryException; +import javax.jcr.Session; +import javax.jcr.SimpleCredentials; + +import org.apache.commons.io.FileUtils; +import org.apache.jackrabbit.core.RepositoryImpl; +import org.apache.jackrabbit.core.config.RepositoryConfig; +import org.apache.jackrabbit.test.JUnitTest; + +/** + * FailUpdateOnJournalExceptionTest checks if + * UpdateEventChannel.updateCreated(Update) throws a ClusterException + * when locking the Journal fails. See JCR-3417 + */ +public class FailUpdateOnJournalExceptionTest extends JUnitTest { + + private RepositoryImpl repo; + + @Override + protected void setUp() throws Exception { + super.setUp(); + deleteAll(); + FileUtils.copyInputStreamToFile( + getClass().getResourceAsStream("repository-with-test-journal.xml"), + new File(getTestDir(), "repository.xml")); + repo = RepositoryImpl.create(RepositoryConfig.create(getTestDir())); + } + + @Override + protected void tearDown() throws Exception { + if (repo != null) { + repo.shutdown(); + } + deleteAll(); + super.tearDown(); + } + + public void testUpdate() throws Exception { + Session s = repo.login(new SimpleCredentials("admin", "admin".toCharArray())); + Node root = s.getRootNode(); + root.addNode("foo"); + s.save(); + root.addNode("bar"); + TestJournal.refuseLock = true; + try { + s.save(); + fail("Session.save() must fail with RepositoryException when Journal cannot be locked."); + } catch (RepositoryException e) { + // expected + } finally { + TestJournal.refuseLock = false; + } + } + + private static void deleteAll() throws IOException { + FileUtils.deleteDirectory(getTestDir()); + } + + private static File getTestDir() throws IOException { + return new File("target", + FailUpdateOnJournalExceptionTest.class.getSimpleName()); + } + +} Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/FailUpdateOnJournalExceptionTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/FailUpdateOnJournalExceptionTest.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Rev URL Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestAll.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestAll.java?rev=1378004&r1=1378003&r2=1378004&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestAll.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestAll.java Tue Aug 28 07:22:58 2012 @@ -41,6 +41,7 @@ public class TestAll extends TestCase { suite.addTestSuite(ClusterSyncTest.class); suite.addTestSuite(DbClusterTest.class); suite.addTestSuite(DbClusterTestJCR3162.class); + suite.addTestSuite(FailUpdateOnJournalExceptionTest.class); return suite; } Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestJournal.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestJournal.java?rev=1378004&view=auto ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestJournal.java (added) +++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestJournal.java Tue Aug 28 07:22:58 2012 @@ -0,0 +1,38 @@ +/* + * 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.cluster; + +import org.apache.jackrabbit.core.journal.JournalException; +import org.apache.jackrabbit.core.journal.MemoryJournal; + +/** +* TestJournal extends the MemoryJournal with a static hook to +* refuse lock acquisition. +*/ +public final class TestJournal extends MemoryJournal { + + static boolean refuseLock = false; + + @Override + protected void doLock() throws JournalException { + if (refuseLock) { + throw new JournalException("lock refused"); + } else { + super.doLock(); + } + } +} Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestJournal.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestJournal.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Rev URL Copied: jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository-with-test-journal.xml (from r1377607, jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository-h2.xml) URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository-with-test-journal.xml?p2=jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository-with-test-journal.xml&p1=jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository-h2.xml&r1=1377607&r2=1378004&rev=1378004&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository-h2.xml (original) +++ jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository-with-test-journal.xml Tue Aug 28 07:22:58 2012 @@ -158,14 +158,7 @@ Cluster configuration with system variables. --> - - - - - - - - +