From b151c0ee395681f8f402491b575e373b55be059e Mon Sep 17 00:00:00 2001
From: "Brian S. O'Neill" <bronee@gmail.com>
Date: Thu, 22 May 2008 00:43:45 +0000
Subject: Fix automatic replication repair which might sometimes throw
 IllegalStateException.

---
 .../carbonado/repo/replicated/ReplicationTrigger.java    | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

(limited to 'src/main/java/com/amazon')

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 3ab69c0..bdacca4 100644
--- a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java
+++ b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java
@@ -294,18 +294,16 @@ class ReplicationTrigger<S extends Storable> extends Trigger<S> {
                     }
                 }
             } else {
-                try {
-                    if (!master.tryLoad()) {
-                        // Both are missing -- no repair needed.
-                        return;
-                    }
-                } catch (IllegalStateException e) {
-                    // Can be caused by not fully defining the primary key on
-                    // the replica, but an alternate key is. The insert will
-                    // fail anyhow, so don't try to repair.
+                if (!master.tryLoad()) {
+                    // Both are missing -- no repair needed.
                     return;
                 }
             }
+        } catch (IllegalStateException e) {
+            // Can be caused by not fully defining the primary key on the
+            // replica, but an alternate key is. The insert will fail anyhow,
+            // so don't try to repair.
+            return;
         } catch (FetchException e) {
             throw e.toPersistException();
         }
-- 
cgit v1.2.3