summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/repo/replicated
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2010-08-26 00:31:18 +0000
committerBrian S. O'Neill <bronee@gmail.com>2010-08-26 00:31:18 +0000
commit7283752c177a5d38776905f0fa115c2405ae2175 (patch)
tree15a3ee64ca867686ca9b54fe5e7c6f50d6f7b0e4 /src/main/java/com/amazon/carbonado/repo/replicated
parent754b0ca594680502727eb71da755d6a41c9d210f (diff)
More robust corruption repairs.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo/replicated')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java
index 0e9281e..d29d568 100644
--- a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java
+++ b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java
@@ -18,6 +18,8 @@
package com.amazon.carbonado.repo.replicated;
+import java.util.Map;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -343,7 +345,28 @@ class ReplicationTrigger<S extends Storable> extends Trigger<S> {
// properties. Be sure not to copy nulls from old replica to new
// replica, in case new non-nullable properties have been added. This
// is why copyUnequalProperties is called instead of copyAllProperties.
- replicaEntry.copyUnequalProperties(newReplicaEntry);
+ try {
+ replicaEntry.copyUnequalProperties(newReplicaEntry);
+ } catch (IllegalArgumentException e) {
+ // Some property cannot be copied, so copy one at a time and skip
+ // the broken one.
+ Map<String,Object> propertyMap = replicaEntry.propertyMap();
+ for (Map.Entry<String, Object> entry : propertyMap.entrySet()) {
+ String name = entry.getKey();
+ Object oldValue = entry.getValue();
+ try {
+ Object newValue = newReplicaEntry.getPropertyValue(name);
+ if (oldValue == null ? newValue != null : !oldValue.equals(newValue)) {
+ newReplicaEntry.setPropertyValue(name, oldValue);
+ }
+ } catch (IllegalArgumentException e2) {
+ // Skip it.
+ } catch (UnsupportedOperationException e2) {
+ // Skip it.
+ }
+ }
+ }
+
// Calling copyAllProperties will skip unsupported independent
// properties in master, thus preserving old independent property values.
masterEntry.copyAllProperties(newReplicaEntry);