Fix related to partial rollback after failed open() in BTree ops.

git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_indexes@381 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeOpHelper.java b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeOpHelper.java
index eeea95f..cf4be8f 100644
--- a/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeOpHelper.java
+++ b/hyracks-storage-am-btree/src/main/java/edu/uci/ics/hyracks/storage/am/btree/dataflow/BTreeOpHelper.java
@@ -83,12 +83,20 @@
 		break;
 		
 		}
-
+		
         int fileId = fileMapProvider.lookupFileId(f);		
-        bufferCache.openFile(fileId);
+        try {
+        	bufferCache.openFile(fileId);
+        } catch(HyracksDataException e) {
+        	// revert state of buffer cache since file failed to open
+        	if(!fileIsMapped) {
+        		bufferCache.deleteFile(fileId);
+        	}
+        	throw e;
+        }
         
-        // only set btreeFileId member when open() succeeds, 
-        // otherwise rollback will try to close the file that failed to open
+        // only set btreeFileId member when openFile() succeeds, 
+        // otherwise deinit() will try to close the file that failed to open
         btreeFileId = fileId;
 
 		interiorFrame = opDesc.getInteriorFactory().getFrame();