diff options
author | Dominik Stadler <centic@apache.org> | 2021-01-07 06:52:57 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2021-01-07 06:52:57 +0000 |
commit | 4bc450ef5f7544d9918d0f560e7b5f4356ae1b81 (patch) | |
tree | 9c10a255995e8d58e764c6eca91508cb8a7b7ad8 /src/ooxml | |
parent | 1882dc74c992997994860899e32900a79deab002 (diff) | |
download | poi-4bc450ef5f7544d9918d0f560e7b5f4356ae1b81.tar.gz poi-4bc450ef5f7544d9918d0f560e7b5f4356ae1b81.zip |
Properly close file handles in extractors and when handling password-protected files
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885229 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml')
-rw-r--r-- | src/ooxml/java/org/apache/poi/ooxml/extractor/POIXMLExtractorFactory.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ooxml/java/org/apache/poi/ooxml/extractor/POIXMLExtractorFactory.java b/src/ooxml/java/org/apache/poi/ooxml/extractor/POIXMLExtractorFactory.java index 2d90b46f20..8cad08609d 100644 --- a/src/ooxml/java/org/apache/poi/ooxml/extractor/POIXMLExtractorFactory.java +++ b/src/ooxml/java/org/apache/poi/ooxml/extractor/POIXMLExtractorFactory.java @@ -240,8 +240,6 @@ public final class POIXMLExtractorFactory implements ExtractorProvider { } return null; - } catch (IOException e) { - throw e; } catch (Error | RuntimeException | XmlException | OpenXML4JException e) { // NOSONAR throw new IOException(e); } @@ -271,6 +269,13 @@ public final class POIXMLExtractorFactory implements ExtractorProvider { } try (InputStream is = dec.getDataStream(poifsDir)) { return create(is, password); + } finally { + // we should close the underlying file-system as all information + // is read now and we should make sure that resources are freed + POIFSFileSystem fs = poifsDir.getFileSystem(); + if (fs != null) { + fs.close(); + } } } catch (IOException | RuntimeException e) { throw e; |