[jboss-cvs] JBossAS SVN: r87519 - trunk/cluster/src/main/org/jboss/profileservice/cluster/repository.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Apr 17 15:34:39 EDT 2009
Author: bstansberry at jboss.com
Date: 2009-04-17 15:34:38 -0400 (Fri, 17 Apr 2009)
New Revision: 87519
Modified:
trunk/cluster/src/main/org/jboss/profileservice/cluster/repository/DefaultSynchronizationPolicy.java
Log:
[JBAS-5552] Avoid NPE when sender discrepancy is unknown
Modified: trunk/cluster/src/main/org/jboss/profileservice/cluster/repository/DefaultSynchronizationPolicy.java
===================================================================
--- trunk/cluster/src/main/org/jboss/profileservice/cluster/repository/DefaultSynchronizationPolicy.java 2009-04-17 19:26:12 UTC (rev 87518)
+++ trunk/cluster/src/main/org/jboss/profileservice/cluster/repository/DefaultSynchronizationPolicy.java 2009-04-17 19:34:38 UTC (rev 87519)
@@ -70,7 +70,7 @@
}
else
{
- TimestampDiscrepancy addDiscrepancy = timestampService.getTimestampDiscrepancy(toAdd.getOriginatingNode(), false);
+ TimestampDiscrepancy addDiscrepancy = getTimestampDiscrepancy(toAdd.getOriginatingNode(), false);
long adjustedTimestamp = addDiscrepancy.getMinLocalTimestamp(toAdd.getTimestamp());
return adjustedTimestamp > System.currentTimeMillis() - getRemovalTrackingTime();
}
@@ -84,8 +84,8 @@
protected boolean acceptReincarnation(RepositoryItemMetadata reincarnation, RepositoryItemMetadata current,
boolean merge)
{
- TimestampDiscrepancy addDiscrepancy = timestampService.getTimestampDiscrepancy(reincarnation.getOriginatingNode(), false);
- TimestampDiscrepancy deadDiscrepancy = timestampService.getTimestampDiscrepancy(current.getOriginatingNode(), false);
+ TimestampDiscrepancy addDiscrepancy = getTimestampDiscrepancy(reincarnation.getOriginatingNode(), false);
+ TimestampDiscrepancy deadDiscrepancy = getTimestampDiscrepancy(current.getOriginatingNode(), false);
return isChangeMoreRecent(reincarnation, current, addDiscrepancy, deadDiscrepancy, false);
}
@@ -103,8 +103,8 @@
return false;
}
- TimestampDiscrepancy senderTimestampDiscrepancy = timestampService.getTimestampDiscrepancy(sendersView.getOriginatingNode(), false);
- TimestampDiscrepancy currentTimestampDiscrepancy = timestampService.getTimestampDiscrepancy(current.getOriginatingNode(), false);
+ TimestampDiscrepancy senderTimestampDiscrepancy = getTimestampDiscrepancy(sendersView.getOriginatingNode(), false);
+ TimestampDiscrepancy currentTimestampDiscrepancy = getTimestampDiscrepancy(current.getOriginatingNode(), false);
return isChangeMoreRecent(sendersView, current, senderTimestampDiscrepancy, currentTimestampDiscrepancy, true);
}
@@ -117,8 +117,8 @@
protected boolean acceptUpdate(RepositoryItemMetadata update, RepositoryItemMetadata current,
boolean merge)
{
- TimestampDiscrepancy updateDiscrepancy = timestampService.getTimestampDiscrepancy(update.getOriginatingNode(), false);
- TimestampDiscrepancy currentTimestampDiscrepancy = timestampService.getTimestampDiscrepancy(current.getOriginatingNode(), false);
+ TimestampDiscrepancy updateDiscrepancy = getTimestampDiscrepancy(update.getOriginatingNode(), false);
+ TimestampDiscrepancy currentTimestampDiscrepancy = getTimestampDiscrepancy(current.getOriginatingNode(), false);
return isChangeMoreRecent(update, current, updateDiscrepancy, currentTimestampDiscrepancy, false);
}
@@ -128,6 +128,11 @@
private static boolean isChangeMoreRecent(RepositoryItemMetadata toChange, RepositoryItemMetadata current,
TimestampDiscrepancy senderTimestampDiscrepancy, TimestampDiscrepancy currentTimestampDiscrepancy, boolean equalAllowed)
{
+ if (senderTimestampDiscrepancy == null)
+ {
+ // Just have to hope for the best
+ senderTimestampDiscrepancy = TimestampDiscrepancy.NO_DISCREPANCY;
+ }
if (currentTimestampDiscrepancy == null)
{
// Just have to hope for the best
@@ -147,5 +152,12 @@
}
return equalAllowed ? senderTime > currentTime :senderTime > currentTime;
}
+
+ private TimestampDiscrepancy getTimestampDiscrepancy(String originatingNode, boolean allowStatusCheck)
+ {
+ TimestampDiscrepancy td = timestampService.getTimestampDiscrepancy(originatingNode, allowStatusCheck);
+ // If we don't have a record for the originator, use NO_DISCREPANCY and hope for the best
+ return td == null ? TimestampDiscrepancy.NO_DISCREPANCY : td;
+ }
}
More information about the jboss-cvs-commits
mailing list