Till Westmann has submitted this change and it was merged.

Change subject: [NO ISSUE] Factor out common error handling code
......................................................................


[NO ISSUE] Factor out common error handling code

- user model changes: no
- storage format changes: no
- interface changes: no

Change-Id: I896d4242d39b72e7c322077ac5c99b0e63f0926c
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2366
Sonar-Qube: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhub...@apache.org>
---
M 
hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
1 file changed, 9 insertions(+), 37 deletions(-)

Approvals:
  Anon. E. Moose #1000171: 
  Jenkins: Verified; No violations found; ; Verified
  Murtadha Hubail: Looks good to me, approved



diff --git 
a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
 
b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
index 5a95af0..908a5c2 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/AbstractLSMIndex.java
@@ -719,71 +719,43 @@
             FlushOperation flushOp = (FlushOperation) operation;
             LOGGER.log(Level.INFO, "Flushing component with id: " + 
flushOp.getFlushingComponent().getId());
         }
-        ILSMDiskComponent component = null;
         try {
-            component = doFlush(operation);
-            return component;
+            return doFlush(operation);
         } catch (Exception e) {
             LOGGER.error("Fail to execute flush " + this, e);
-            // clean up component
-            try {
-                cleanUpFiles(operation);
-            } catch (HyracksDataException e1) {
-                e.addSuppressed(e1);
-            }
+            cleanUpFiles(operation, e);
             throw HyracksDataException.create(e);
         }
-
     }
 
     @Override
     public final ILSMDiskComponent merge(ILSMIOOperation operation) throws 
HyracksDataException {
         ILSMIndexAccessor accessor = operation.getAccessor();
         ILSMIndexOperationContext opCtx = accessor.getOpContext();
-        ILSMDiskComponent component = null;
         try {
-            component = opCtx.getOperation() == 
IndexOperation.DELETE_DISK_COMPONENTS ? EmptyComponent.INSTANCE
+            return opCtx.getOperation() == 
IndexOperation.DELETE_DISK_COMPONENTS ? EmptyComponent.INSTANCE
                     : doMerge(operation);
-            return component;
         } catch (Exception e) {
             LOGGER.error("Fail to execute merge " + this, e);
-            // clean up component
-            try {
-                cleanUpFiles(operation);
-            } catch (HyracksDataException e1) {
-                e.addSuppressed(e1);
-            }
+            cleanUpFiles(operation, e);
             throw HyracksDataException.create(e);
         }
-
     }
 
-    protected void cleanUpFiles(ILSMIOOperation operation) throws 
HyracksDataException {
+    protected void cleanUpFiles(ILSMIOOperation operation, Exception e) {
         LSMComponentFileReferences componentFiles = 
operation.getComponentFiles();
         if (componentFiles == null) {
             return;
         }
         FileReference[] files = componentFiles.getFileReferences();
-        HyracksDataException exception = null;
         for (FileReference file : files) {
             try {
-                cleanUpFile(file);
-            } catch (HyracksDataException e) {
-                if (exception == null) {
-                    exception = e;
-                } else {
-                    exception.addSuppressed(e);
+                if (file != null) {
+                    diskBufferCache.deleteFile(file);
                 }
+            } catch (HyracksDataException hde) {
+                e.addSuppressed(hde);
             }
-        }
-        if (exception != null) {
-            throw exception;
-        }
-    }
-
-    protected void cleanUpFile(FileReference file) throws HyracksDataException 
{
-        if (file != null) {
-            diskBufferCache.deleteFile(file);
         }
     }
 

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2366
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I896d4242d39b72e7c322077ac5c99b0e63f0926c
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Till Westmann <ti...@apache.org>
Gerrit-Reviewer: Anon. E. Moose #1000171
Gerrit-Reviewer: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Murtadha Hubail <mhub...@apache.org>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>

Reply via email to