[jbosscache-commits] JBoss Cache SVN: r6714 - in core/support-branches/1.4.1.SP9_JBCACHE-1406: src/org/jboss/cache and 1 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Fri Sep 12 17:48:34 EDT 2008
Author: jiwils
Date: 2008-09-12 17:48:34 -0400 (Fri, 12 Sep 2008)
New Revision: 6714
Added:
core/support-branches/1.4.1.SP9_JBCACHE-1406/tests/functional/org/jboss/cache/RemoveOnTxTest.java
Modified:
core/support-branches/1.4.1.SP9_JBCACHE-1406/build.xml
core/support-branches/1.4.1.SP9_JBCACHE-1406/src/org/jboss/cache/TreeCache.java
Log:
Merged 6690 - 6692 of the 1.4.x Branch for JBPAPP-1171 and JBCACHE-1406.
Modified: core/support-branches/1.4.1.SP9_JBCACHE-1406/build.xml
===================================================================
--- core/support-branches/1.4.1.SP9_JBCACHE-1406/build.xml 2008-09-12 21:40:49 UTC (rev 6713)
+++ core/support-branches/1.4.1.SP9_JBCACHE-1406/build.xml 2008-09-12 21:48:34 UTC (rev 6714)
@@ -392,7 +392,7 @@
<target name="one-test-aop" depends="generateClassLoader, compile,unittests-init"
description="Runs a single unit test">
- <junit printsummary="yes" timeout="${junit.timeout}" fork="yes">
+ <junit printsummary="yes" timeout="${junit.timeout}" fork="yes" maxmemory="512">
<jvmarg value="-Djboss.aop.path=${output.etc.dir}/jboss-aop.xml"/>
<jvmarg value="-Xbootclasspath/p:${bootclasspath}"/>
<!-- start of Optimizeit support
Modified: core/support-branches/1.4.1.SP9_JBCACHE-1406/src/org/jboss/cache/TreeCache.java
===================================================================
--- core/support-branches/1.4.1.SP9_JBCACHE-1406/src/org/jboss/cache/TreeCache.java 2008-09-12 21:40:49 UTC (rev 6713)
+++ core/support-branches/1.4.1.SP9_JBCACHE-1406/src/org/jboss/cache/TreeCache.java 2008-09-12 21:48:34 UTC (rev 6714)
@@ -4303,6 +4303,13 @@
else
{
if (log.isDebugEnabled()) log.debug("Node " + f + " NOT marked for removal as expected, not removing!");
+ //also check whether children are marked for deletion, JBCACHE-1406
+ Iterator iterator = n.getChildren(true).values().iterator();
+ while (iterator.hasNext())
+ {
+ DataNode data = (DataNode) iterator.next();
+ realRemove(data.getFqn(), skipMarkerCheck);
+ }
}
}
Copied: core/support-branches/1.4.1.SP9_JBCACHE-1406/tests/functional/org/jboss/cache/RemoveOnTxTest.java (from rev 6713, core/branches/1.4.X/tests/functional/org/jboss/cache/RemoveOnTxTest.java)
===================================================================
--- core/support-branches/1.4.1.SP9_JBCACHE-1406/tests/functional/org/jboss/cache/RemoveOnTxTest.java (rev 0)
+++ core/support-branches/1.4.1.SP9_JBCACHE-1406/tests/functional/org/jboss/cache/RemoveOnTxTest.java 2008-09-12 21:48:34 UTC (rev 6714)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.cache;
+
+import junit.framework.TestCase;
+
+import javax.transaction.TransactionManager;
+import javax.transaction.Transaction;
+
+/**
+ * When deleting a node in TX and adding one of it's parrents in same tx, the node node does not get deleted when
+ * tx finishes. This tests is for reproducing the issue above.
+ */
+public class RemoveOnTxTest extends TestCase
+{
+ TreeCache cache;
+ protected void setUp() throws Exception
+ {
+ cache = new TreeCache();
+ PropertyConfigurator config = new PropertyConfigurator();
+ config.configure(cache, "META-INF/local-service.xml");
+ cache.create();
+ cache.start();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ cache.stop();
+ cache.destroy();
+ }
+
+ public void testFailure() throws Exception
+ {
+
+ TransactionManager tm = cache.getTransactionManager();
+ try
+ {
+ tm.begin();
+ print("put()");
+ cache.put("/a/b/c", "test", "test");
+ assertTrue(cache.get("/a/b/c", "test").equals("test"));
+ print("remove()");
+ cache.remove("/a/b");
+ assertTrue(!cache.exists("/a/b"));
+ assertTrue(!cache.exists("/a/b/c"));
+ cache.put("/a/b/d", "test1", "test1");
+ assertTrue(!cache.exists("/a/b/c"));
+ assertTrue(cache.exists("/a/b/d"));
+ print("Exists? " + cache.exists("/a/b/c"));
+ print("get(): " + cache.get("/a/b/c", "test"));
+ tm.commit();
+ assertTrue(cache.peek(Fqn.fromString("/a/b/c")) == null);
+ assertTrue(!cache.exists("/a/b/c"));
+ assertTrue(cache.exists("/a/b/d"));
+ cache.printLockInfo();
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ tm.rollback();
+ }
+ cache.printLockInfo();
+ System.out.println(" lock info " + cache.printLockInfo());
+ try
+ {
+ tm.begin();
+ print(cache.exists("/a/b/c"));
+ print("get(): " + cache.get("/a/b/c", "test"));
+ print("get(): " + cache.get("/a/b/c", "test"));
+ Transaction t = tm.suspend();
+ try
+ {
+ cache.putFailFast("/a/b/c", "test", "test", 0);
+ } catch (Exception ignore)
+ {
+ ignore.printStackTrace();
+ }
+ tm.resume(t);
+ print("get(): " + cache.get("/a/b/c", "test"));
+ print(cache.exists("/a/b/c"));
+ cache.put("/a/b/c", "test", "test");
+ print(cache.exists("/a/b/c"));
+ tm.commit();
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ tm.rollback();
+ }
+ }
+
+ private void print(Object s)
+ {
+ System.out.println(s);
+ }
+
+ private void print(boolean s)
+ {
+ System.out.println(s);
+ }
+
+ public void testReal() throws Exception
+ {
+ TransactionManager tm = cache.getTransactionManager();
+ tm.begin();
+ print("put()");
+ cache.put("/a/b/c", "test", "test");
+ assertTrue(cache.get("/a/b/c", "test").equals("test"));
+ print("remove()");
+ cache.remove("/a/b");
+ assertTrue(!cache.exists("/a/b"));
+ assertTrue(!cache.exists("/a/b/c"));
+ cache.put("/a/b/d", "test1", "test1");
+ assertTrue(!cache.exists("/a/b/c"));
+ assertTrue(cache.exists("/a/b/d"));
+ print("Exists? " + cache.exists("/a/b/c"));
+ print("get(): " + cache.get("/a/b/c", "test"));
+ tm.commit();
+ assertNull(cache.peek(Fqn.fromString("/a/b/c")));
+ assertTrue(!cache.exists("/a/b/c"));
+ assertTrue(cache.exists("/a/b/d"));
+ cache.printLockInfo();
+ }
+
+ public void testSimplified() throws Exception
+ {
+ TransactionManager tm = cache.getTransactionManager();
+ tm.begin();
+ print("put()");
+ cache.put("/a/b/c", "test", "test");
+ assertTrue(cache.peek(Fqn.fromString("/a/b/c")) != null);
+ cache.remove("/a/b");
+ assertTrue(cache.peek(Fqn.fromString("/a/b/c")).getDataKeys().contains("__JBOSS_MARKED_FOR_REMOVAL"));
+ tm.commit();
+ assertTrue(cache.peek(Fqn.fromString("/a/b/c")) == null);
+ }
+}
More information about the jbosscache-commits
mailing list