summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/repo
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2012-05-01 18:08:27 +0000
committerJesse Morgan <jesse@jesterpm.net>2012-05-01 18:08:27 +0000
commit64f320d5259ac229bf1040bab005d1a72b80a194 (patch)
tree98ace2fe6a9d3e6711a46e473544a29ba686556a /src/main/java/com/amazon/carbonado/repo
parentbbb9c4d99701a5f6035060e680d3f2c774f53212 (diff)
Fixed add trigger exception in subsequent constructions of IndexedStorage when the first throws an exception.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java b/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java
index 7552834..b00b0b4 100644
--- a/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java
+++ b/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java
@@ -75,7 +75,7 @@ class IndexedStorage<S extends Storable> implements Storage<S>, StorageAccess<S>
private final StorableIndexSet<S> mQueryableIndexSet;
private final QueryEngine<S> mQueryEngine;
-
+
IndexedStorage(IndexAnalysis<S> analysis) throws RepositoryException {
mRepository = analysis.repository;
mMasterStorage = analysis.masterStorage;
@@ -89,14 +89,22 @@ class IndexedStorage<S extends Storable> implements Storage<S>, StorageAccess<S>
}
}
- // Okay, now start doing some damage. First, remove unnecessary indexes.
- for (StorableIndex<S> index : analysis.removeIndexSet) {
- removeIndex(index);
- }
+ try {
+ // Okay, now start doing some damage. First, remove unnecessary indexes.
+ for (StorableIndex<S> index : analysis.removeIndexSet) {
+ removeIndex(index);
+ }
- // Now add new indexes.
- for (StorableIndex<S> index : analysis.addIndexSet) {
- registerIndex((ManagedIndex) mAllIndexInfoMap.get(index));
+ // Now add new indexes.
+ for (StorableIndex<S> index : analysis.addIndexSet) {
+ registerIndex((ManagedIndex) mAllIndexInfoMap.get(index));
+ }
+ } catch (RepositoryException e) {
+ // Something went wrong. Cleanup the trigger to avoid an exception if we try again.
+ if (analysis.indexesTrigger != null) {
+ removeTrigger(analysis.indexesTrigger);
+ }
+ throw e;
}
mQueryEngine = new QueryEngine<S>(mMasterStorage.getStorableType(), mRepository);