diff --git a/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java b/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java index 94a3fc023..cfe37a03b 100644 --- a/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java +++ b/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java @@ -167,6 +167,10 @@ public class ExtractorFactory { // ensure file-handle release IOUtils.closeQuietly(fs); throw e; + } catch (Error e) { + // ensure file-handle release + IOUtils.closeQuietly(fs); + throw e; } } @@ -283,6 +287,11 @@ public class ExtractorFactory { // we need to revert the package to not re-write the file via close(), which is very likely not wanted for a TextExtractor! pkg.revert(); throw e; + } catch (Error e) { + // ensure that we close the package again if there is an error opening it, however + // we need to revert the package to not re-write the file via close(), which is very likely not wanted for a TextExtractor! + pkg.revert(); + throw e; } }