From 44ab9fdec458b51577bf806dc542a22f8b632410 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Mon, 24 Nov 2008 23:45:26 +0000 Subject: Allow primary record to be deleted if corrupt. --- .../amazon/carbonado/repo/indexed/IndexesTrigger.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/amazon/carbonado') diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/IndexesTrigger.java b/src/main/java/com/amazon/carbonado/repo/indexed/IndexesTrigger.java index ab718e4..678769d 100644 --- a/src/main/java/com/amazon/carbonado/repo/indexed/IndexesTrigger.java +++ b/src/main/java/com/amazon/carbonado/repo/indexed/IndexesTrigger.java @@ -18,6 +18,9 @@ package com.amazon.carbonado.repo.indexed; +import org.apache.commons.logging.LogFactory; + +import com.amazon.carbonado.CorruptEncodingException; import com.amazon.carbonado.FetchException; import com.amazon.carbonado.PersistException; import com.amazon.carbonado.Storable; @@ -89,10 +92,19 @@ class IndexesTrigger extends Trigger { // Delete index entries referenced by existing storable. S copy = (S) storable.copy(); try { - if (copy.tryLoad()) { - for (ManagedIndex managed : mManagedIndexes) { - managed.deleteIndexEntry(copy); + try { + if (!copy.tryLoad()) { + return null; } + } catch (CorruptEncodingException e) { + LogFactory.getLog(IndexedStorage.class) + .warn("Unable to delete index entries because primary record is corrupt: " + + copy.toStringKeyOnly(), e); + return null; + } + + for (ManagedIndex managed : mManagedIndexes) { + managed.deleteIndexEntry(copy); } } catch (FetchException e) { throw e.toPersistException(); -- cgit v1.2.3