[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...
Manik Surtani
msurtani at jboss.com
Wed Dec 6 11:28:37 EST 2006
User: msurtani
Date: 06/12/06 11:28:37
Modified: src/org/jboss/cache/interceptors
OptimisticReplicationInterceptor.java
OptimisticValidatorInterceptor.java
Log:
JBCACHE-894
Revision Changes Path
1.30 +1 -0 JBossCache/src/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticReplicationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- OptimisticReplicationInterceptor.java 13 Nov 2006 14:20:32 -0000 1.29
+++ OptimisticReplicationInterceptor.java 6 Dec 2006 16:28:37 -0000 1.30
@@ -297,6 +297,7 @@
private DataVersion getVersionToBroadcast(TransactionWorkspace w, Fqn f)
{
WorkspaceNode n = w.getNode(f);
+ if (n == null) return null;
if (w.isVersioningImplicit())
{
DefaultDataVersion v = (DefaultDataVersion) n.getVersion();
1.45 +17 -9 JBossCache/src/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticValidatorInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- OptimisticValidatorInterceptor.java 25 Nov 2006 18:40:18 -0000 1.44
+++ OptimisticValidatorInterceptor.java 6 Dec 2006 16:28:37 -0000 1.45
@@ -13,7 +13,6 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.OptimisticTreeNode;
-import org.jboss.cache.TreeCacheProxyImpl;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.optimistic.DataVersion;
@@ -24,7 +23,6 @@
import javax.transaction.Transaction;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
@@ -119,7 +117,7 @@
if (trace) log.trace("validating version for node " + fqn);
OptimisticTreeNode realNode;
- realNode = (OptimisticTreeNode)cache.peek(fqn);
+ realNode = (OptimisticTreeNode) cache.peek(fqn);
if (workspaceNode.isCreated())
{
@@ -141,12 +139,14 @@
}
if (workspaceNode.getVersion() == null)
+ {
throw new DataVersioningException("No version for workspace node");
+ }
DataVersion rnv = realNode.getVersion();
DataVersion wnv = workspaceNode.getVersion();
// test that the 2 DataVersion types match up
- if (!rnv.getClass().equals(wnv.getClass()))
+ if (!rnv.getClass().equals(wnv.getClass()) && checkNotInitialRootVersion(realNode))
{
throw new DataVersioningException("Attempting to apply data version of type " + workspaceNode.getVersion().getClass() + " to a node that already contains version of type " + realNode.getVersion().getClass());
}
@@ -159,6 +159,10 @@
}
}
+ private boolean checkNotInitialRootVersion(OptimisticTreeNode n)
+ {
+ return !n.getFqn().isRoot() || !(n.getVersion() instanceof DefaultDataVersion) || n.getVersion() != DefaultDataVersion.ZERO;
+ }
private void commit(GlobalTransaction gtx)
{
@@ -198,7 +202,9 @@
cache.getNotifier().notifyNodeRemoved(dNode.getFqn(), true, dNode.getNodeSPI().getRawData());
DataNode parent = (DataNode) dNode.getParent();
if (parent == null)
+ {
throw new IllegalStateException("dNode " + dNode + " has no parent");
+ }
parent.removeChild(dNode.getFqn().getLast());
cache.getNotifier().notifyNodeRemoved(dNode.getFqn(), false, null);
}
@@ -224,7 +230,9 @@
if (needsNotify)
{
if (log.isTraceEnabled())
+ {
log.trace("inserting merged data " + mergedData + " for " + current);
+ }
cache.getNotifier().notifyNodeModified(wrappedNode.getFqn(), true, rawData);
}
More information about the jboss-cvs-commits
mailing list