ExtractorFactory: Try to close resources also on Errors to avoid keeping files open too long

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1802630 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2017-07-21 18:19:11 +00:00
parent db1b62efe7
commit c76672b8aa
1 changed files with 9 additions and 0 deletions

View File

@ -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;
}
}