diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2007-05-14 03:02:14 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2007-05-14 03:02:14 +0000 |
commit | ad33d5c5dcbf3b481731dfadda995cd95ac73af2 (patch) | |
tree | 1412cf6a236fbb741d7cd2eae77388d17431f52c /src/main/java/com/amazon/carbonado/spi | |
parent | 2d5fb771996cb79963b7d763b9148e6f1c1c98cb (diff) |
More lob and sequence tests; LobEngine fixes.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/spi')
-rw-r--r-- | src/main/java/com/amazon/carbonado/spi/LobEngine.java | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/main/java/com/amazon/carbonado/spi/LobEngine.java b/src/main/java/com/amazon/carbonado/spi/LobEngine.java index d6ab994..8cc1bf9 100644 --- a/src/main/java/com/amazon/carbonado/spi/LobEngine.java +++ b/src/main/java/com/amazon/carbonado/spi/LobEngine.java @@ -295,17 +295,16 @@ public class LobEngine { data.close();
}
+ // Close but don't commit the transaction. This close is explicitly
+ // not put into a finally block in order for an exception to cause
+ // the transaction to rollback.
+ out.close(false);
+
if (total < lob.getLength()) {
+ // Adjust length after closing stream to avoid OptimisticLockException.
new BlobImpl(lob).setLength(total);
}
- // Note: Closing Output commits the transaction. No other resources
- // are freed. This close is explicitly not put into a finally block
- // in order for an exception to cause the transaction to rollback.
- out.close();
-
- // This isn't really needed due to closing Output, but it is good
- // practice to include it anyhow.
txn.commit();
} catch (IOException e) {
if (e.getCause() instanceof RepositoryException) {
@@ -1012,7 +1011,11 @@ public class LobEngine { }
@Override
- public synchronized void close() throws IOException {
+ public void close() throws IOException {
+ close(true);
+ }
+
+ synchronized void close(boolean commit) throws IOException {
if (mTxn != null) {
try {
updateBlock();
@@ -1020,14 +1023,18 @@ public class LobEngine { mStoredLob.setLength(mPos);
mStoredLob.update();
}
- mTxn.commit();
+ if (commit) {
+ mTxn.commit();
+ }
} catch (PersistException e) {
throw toIOException(e);
} finally {
- try {
- mTxn.exit();
- } catch (PersistException e) {
- throw toIOException(e);
+ if (commit) {
+ try {
+ mTxn.exit();
+ } catch (PersistException e) {
+ throw toIOException(e);
+ }
}
}
mTxn = null;
|