summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2006-12-01 05:02:37 +0000
committerBrian S. O'Neill <bronee@gmail.com>2006-12-01 05:02:37 +0000
commit80fdb36c2780744f12d3fc527812ecf62980ad8b (patch)
treee73cb9fcfb9829bdea0927a2a69e4d39e739025c
parentcb59d123bee1df3748c9a8ab5acdb3e4a0d97de9 (diff)
Add Storable to CorruptEncodingException when loading from index.
-rw-r--r--RELEASE-NOTES.txt1
-rw-r--r--pom.xml2
-rw-r--r--src/main/java/com/amazon/carbonado/layout/Layout.java2
-rw-r--r--src/main/java/com/amazon/carbonado/layout/LayoutProperty.java6
-rw-r--r--src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java18
-rw-r--r--src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java2
6 files changed, 25 insertions, 6 deletions
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 7d99716..3ef6f98 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -4,6 +4,7 @@ Carbonado change history
1.1-BETA5 to 1.1-BETA6
-------------------------------
- Added automatic repair for broken layout metadata.
+- Add Storable to CorruptEncodingException when loading from index.
- Fix conversion of null lobs.
- Query filter constants appear as SQL constants.
diff --git a/pom.xml b/pom.xml
index a1ec166..90b57ba 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
<artifactId>carbonado</artifactId>
<packaging>jar</packaging>
<name>Carbonado</name>
- <version>1.1-BETA5</version>
+ <version>1.1-BETA6</version>
<description>
Extensible, high performance persistence abstraction layer for Java applications with a relational view to the underlying persistence technology.
</description>
diff --git a/src/main/java/com/amazon/carbonado/layout/Layout.java b/src/main/java/com/amazon/carbonado/layout/Layout.java
index d127835..62e29f2 100644
--- a/src/main/java/com/amazon/carbonado/layout/Layout.java
+++ b/src/main/java/com/amazon/carbonado/layout/Layout.java
@@ -420,7 +420,7 @@ public class Layout {
mStoredLayout.update();
}
for (LayoutProperty property : mAllProperties) {
- property.insert();
+ property.store();
}
}
}
diff --git a/src/main/java/com/amazon/carbonado/layout/LayoutProperty.java b/src/main/java/com/amazon/carbonado/layout/LayoutProperty.java
index 4a7dea1..a0ce48f 100644
--- a/src/main/java/com/amazon/carbonado/layout/LayoutProperty.java
+++ b/src/main/java/com/amazon/carbonado/layout/LayoutProperty.java
@@ -185,7 +185,9 @@ public class LayoutProperty {
return mStoredLayoutProperty.toString();
}
- void insert() throws PersistException {
- mStoredLayoutProperty.insert();
+ void store() throws PersistException {
+ if (!mStoredLayoutProperty.tryInsert()) {
+ mStoredLayoutProperty.update();
+ }
}
}
diff --git a/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java b/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java
index cac1283..8113b32 100644
--- a/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java
+++ b/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java
@@ -124,6 +124,7 @@ public class GenericStorableCodec<S extends Storable> implements StorableCodec<S
cf.setTarget("1.5");
// Declare some types.
+ final TypeDesc storableType = TypeDesc.forClass(Storable.class);
final TypeDesc rawSupportType = TypeDesc.forClass(RawSupport.class);
final TypeDesc byteArrayType = TypeDesc.forClass(byte[].class);
final TypeDesc[] byteArrayParam = {byteArrayType};
@@ -285,13 +286,28 @@ public class GenericStorableCodec<S extends Storable> implements StorableCodec<S
haveCodec.setLocation();
b.checkCast(codecType);
b.loadLocal(actualGeneration);
+ Label tryStartDecode = b.createLabel().setLocation();
b.invokeVirtual(codecType, "getDecoder", decoderType, new TypeDesc[] {TypeDesc.INT});
b.loadThis();
b.loadLocal(b.getParameter(0));
b.invokeInterface(decoderType, "decode", null,
- new TypeDesc[] {TypeDesc.forClass(Storable.class), byteArrayType});
+ new TypeDesc[] {storableType, byteArrayType});
+ Label tryEndDecode = b.createLabel().setLocation();
b.returnVoid();
+
+ // If unable to decode, fill out exception.
+ b.exceptionHandler(tryStartDecode, tryEndDecode,
+ CorruptEncodingException.class.getName());
+ TypeDesc exType = TypeDesc.forClass(CorruptEncodingException.class);
+ LocalVariable exVar = b.createLocalVariable(null, TypeDesc.OBJECT);
+ b.storeLocal(exVar);
+ b.loadLocal(exVar);
+ b.loadThis();
+ b.invokeVirtual(exType, "setStorableWithPrimaryKey", null,
+ new TypeDesc[] {storableType});
+ b.loadLocal(exVar);
+ b.throwObject();
}
return ci.defineClass(cf);
diff --git a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java
index 695f520..28123a3 100644
--- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java
+++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java
@@ -512,7 +512,7 @@ public class BDBRepositoryBuilder extends AbstractRepositoryBuilder {
* ever persisted.
*/
public void setLogInMemory(boolean logInMemory) {
- mLogInMemory = true;
+ mLogInMemory = logInMemory;
}
/**