]> source.dussan.org Git - poi.git/commitdiff
In NPOIFS, close the file we opened in more exception cases
authorNick Burch <nick@apache.org>
Wed, 5 Jan 2011 09:42:00 +0000 (09:42 +0000)
committerNick Burch <nick@apache.org>
Wed, 5 Jan 2011 09:42:00 +0000 (09:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1055379 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java

index 8a7b6833153b54331be98f3de8cc0d3ab49e0a47..58d77be69a01ebfc864b0cd75d8ecf4eaf625d0f 100644 (file)
@@ -183,6 +183,14 @@ public class NPOIFSFileSystem extends BlockStore
              channel.close();
           }
           throw e;
+       } catch(RuntimeException e) {
+          // Comes from Iterators etc.
+          // TODO Decide if we can handle these better whilst
+          //  still sticking to the iterator contract
+          if(closeChannelOnError) {
+             channel.close();
+          }
+          throw e;
        }
     }