You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kf...@apache.org on 2012/04/19 04:27:36 UTC

svn commit: r1327784 - /tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java

Author: kfujino
Date: Thu Apr 19 02:27:35 2012
New Revision: 1327784

URL: http://svn.apache.org/viewvc?rev=1327784&view=rev
Log:
Apply Konstantin's suggestion.
"if (diff && (isDirty || complete))" block was executed regardless of the value of "complete".

Modified:
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java?rev=1327784&r1=1327783&r2=1327784&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java Thu Apr 19 02:27:35 2012
@@ -401,10 +401,11 @@ public abstract class AbstractReplicated
         if ( entry == null ) return;
         if ( !entry.isSerializable() ) return;
         if (entry.isPrimary() && entry.getBackupNodes()!= null && entry.getBackupNodes().length > 0) {
-            Object value = entry.getValue();
             //check to see if we need to replicate this object isDirty()||complete || isAccessReplicate()
-            boolean isDirty = ((value instanceof ReplicatedMapEntry) && ((ReplicatedMapEntry) value).isDirty());
-            boolean isAccess = ((value instanceof ReplicatedMapEntry) && ((ReplicatedMapEntry) value).isAccessReplicate());
+            ReplicatedMapEntry rentry = null;
+            if (entry.getValue() instanceof ReplicatedMapEntry) rentry = (ReplicatedMapEntry)entry.getValue();
+            boolean isDirty = rentry != null && rentry.isDirty();
+            boolean isAccess = rentry != null && rentry.isAccessReplicate();
             boolean repl = complete || isDirty || isAccess;
             
             if (!repl) {
@@ -414,10 +415,9 @@ public abstract class AbstractReplicated
                 return;
             }
             //check to see if the message is diffable
-            boolean diff = ((value instanceof ReplicatedMapEntry) && ((ReplicatedMapEntry) value).isDiffable());
+            boolean diff = rentry != null && rentry.isDiffable();
             MapMessage msg = null;
-            if (diff && isDirty) {
-                ReplicatedMapEntry rentry = (ReplicatedMapEntry)entry.getValue();
+            if (diff && (isDirty || complete)) {
                 try {
                     rentry.lock();
                     //construct a diff message
@@ -450,9 +450,7 @@ public abstract class AbstractReplicated
             }
             try {
                 if ( channel!=null && entry.getBackupNodes()!= null && entry.getBackupNodes().length > 0 ) {
-                    if ((entry.getValue() instanceof ReplicatedMapEntry)) {
-                        ((ReplicatedMapEntry)entry.getValue()).setLastTimeReplicated(System.currentTimeMillis());
-                    }
+                    if (rentry != null) rentry.setLastTimeReplicated(System.currentTimeMillis());
                     channel.send(entry.getBackupNodes(), msg, channelSendOptions);
                 }
             } catch (ChannelException x) {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org