don't leak cstores if CStoreEditor rollback fails
authorgmc <gmc@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 26 Sep 2010 02:42:50 +0000 (02:42 +0000)
committergmc <gmc@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 26 Sep 2010 02:42:50 +0000 (02:42 +0000)
Patch by Mike Rylander.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
git-svn-id: svn://svn.open-ils.org/ILS/trunk@17995 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm

index 1788186..9845623 100644 (file)
@@ -294,8 +294,17 @@ sub rollback_savepoint {
 # -----------------------------------------------------------------------------
 sub rollback {
        my $self = shift;
-       $self->xact_rollback;
-       $self->disconnect;
+    my $err;
+    my $ret;
+       try {
+        $self->xact_rollback;
+    } catch Error with  {
+        $err = shift
+    } finally {
+        $ret = $self->disconnect
+    };
+    throw $err if ($err);
+    return $ret;
 }
 
 sub disconnect {
@@ -334,8 +343,17 @@ sub reset {
 # -----------------------------------------------------------------------------
 sub finish {
        my $self = shift;
-       $self->commit;
-       $self->reset;
+    my $err;
+    my $ret;
+       try {
+        $self->commit;
+    } catch Error with  {
+        $err = shift
+    } finally {
+        $ret = $self->reset
+    };
+    throw $err if ($err);
+    return $ret;
 }