diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2009-03-27 00:20:53 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2009-03-27 00:20:53 +0000 |
commit | b04929437cf6cbfd9c2a4a64cb453ce072084a4e (patch) | |
tree | 9363378f31af360c3f9eb063779e16f286f135cb /src/main/java/com/amazon/carbonado/repo | |
parent | 816705790c92d4bfac11e1b5fdd60df940cae839 (diff) |
Make sure FetchException propagates from generated index Storable correctly.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo')
3 files changed, 11 insertions, 8 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/DependentStorableFetcher.java b/src/main/java/com/amazon/carbonado/repo/indexed/DependentStorableFetcher.java index d9e9f32..5141788 100644 --- a/src/main/java/com/amazon/carbonado/repo/indexed/DependentStorableFetcher.java +++ b/src/main/java/com/amazon/carbonado/repo/indexed/DependentStorableFetcher.java @@ -132,7 +132,7 @@ class DependentStorableFetcher<S extends Storable, D extends Storable> { /**
* @return amount added to list
*/
- public int createIndexEntries(D master, List<Storable> indexEntries) {
+ public int createIndexEntries(D master, List<Storable> indexEntries) throws FetchException {
IndexEntryAccessor[] accessors = mIndexEntryAccessors;
int length = accessors.length;
for (int i=0; i<length; i++) {
diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/IndexEntryAccessor.java b/src/main/java/com/amazon/carbonado/repo/indexed/IndexEntryAccessor.java index 1b7f910..e3909c8 100644 --- a/src/main/java/com/amazon/carbonado/repo/indexed/IndexEntryAccessor.java +++ b/src/main/java/com/amazon/carbonado/repo/indexed/IndexEntryAccessor.java @@ -20,6 +20,7 @@ package com.amazon.carbonado.repo.indexed; import java.util.Comparator;
+import com.amazon.carbonado.FetchException;
import com.amazon.carbonado.RepositoryException;
import com.amazon.carbonado.Storable;
import com.amazon.carbonado.Storage;
@@ -46,7 +47,7 @@ public interface IndexEntryAccessor<S extends Storable> extends IndexInfo { * @param indexEntry source of property values
* @param master master whose primary key properties will be set
*/
- void copyToMasterPrimaryKey(Storable indexEntry, S master);
+ void copyToMasterPrimaryKey(Storable indexEntry, S master) throws FetchException;
/**
* Sets all the properties of the given index entry, using the applicable
@@ -55,7 +56,7 @@ public interface IndexEntryAccessor<S extends Storable> extends IndexInfo { * @param indexEntry index entry whose properties will be set
* @param master source of property values
*/
- void copyFromMaster(Storable indexEntry, S master);
+ void copyFromMaster(Storable indexEntry, S master) throws FetchException;
/**
* Returns true if the properties of the given index entry match those
@@ -65,7 +66,7 @@ public interface IndexEntryAccessor<S extends Storable> extends IndexInfo { * @param indexEntry index entry whose properties will be tested
* @param master source of property values
*/
- boolean isConsistent(Storable indexEntry, S master);
+ boolean isConsistent(Storable indexEntry, S master) throws FetchException;
/**
* Repairs the index by inserting missing entries and fixing
diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java b/src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java index 8219ac1..e730c6e 100644 --- a/src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java +++ b/src/main/java/com/amazon/carbonado/repo/indexed/ManagedIndex.java @@ -146,17 +146,17 @@ class ManagedIndex<S extends Storable> implements IndexEntryAccessor<S> { }
// Required by IndexEntryAccessor interface.
- public void copyToMasterPrimaryKey(Storable indexEntry, S master) {
+ public void copyToMasterPrimaryKey(Storable indexEntry, S master) throws FetchException {
mAccessor.copyToMasterPrimaryKey(indexEntry, master);
}
// Required by IndexEntryAccessor interface.
- public void copyFromMaster(Storable indexEntry, S master) {
+ public void copyFromMaster(Storable indexEntry, S master) throws FetchException {
mAccessor.copyFromMaster(indexEntry, master);
}
// Required by IndexEntryAccessor interface.
- public boolean isConsistent(Storable indexEntry, S master) {
+ public boolean isConsistent(Storable indexEntry, S master) throws FetchException {
return mAccessor.isConsistent(indexEntry, master);
}
@@ -561,7 +561,7 @@ class ManagedIndex<S extends Storable> implements IndexEntryAccessor<S> { }
// If index entry already exists, then index might be corrupt.
- {
+ try {
Storable freshEntry = mIndexEntryStorage.prepare();
mAccessor.copyFromMaster(freshEntry, userStorable);
indexEntry.copyVersionProperty(freshEntry);
@@ -571,6 +571,8 @@ class ManagedIndex<S extends Storable> implements IndexEntryAccessor<S> { // user error.
return !isUnique();
}
+ } catch (FetchException e) {
+ throw e.toPersistException();
}
// Run the repair outside a transaction.
|