Properly close internal InputStream in ExtractorFactory#createExtractor(File), see Bugzilla 49147
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@935900 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fe048df54e
commit
d2e1849979
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
<changes>
|
<changes>
|
||||||
<release version="3.7-SNAPSHOT" date="2010-??-??">
|
<release version="3.7-SNAPSHOT" date="2010-??-??">
|
||||||
|
<action dev="POI-DEVELOPERS" type="fix">49147 - Properly close internal InputStream in ExtractorFactory#createExtractor(File)</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">49138 - Fixed locale-sensitive formatters in PackagePropertiesPart</action>
|
<action dev="POI-DEVELOPERS" type="fix">49138 - Fixed locale-sensitive formatters in PackagePropertiesPart</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">49153 - Ensure that CTVectorVariant is included in poi-ooxml-schemas.jar</action>
|
<action dev="POI-DEVELOPERS" type="fix">49153 - Ensure that CTVectorVariant is included in poi-ooxml-schemas.jar</action>
|
||||||
<action dev="POI-DEVELOPERS" type="add">49146 - Added accessors to CoreProperties.Keywords </action>
|
<action dev="POI-DEVELOPERS" type="add">49146 - Added accessors to CoreProperties.Keywords </action>
|
||||||
|
@ -119,17 +119,21 @@ public class ExtractorFactory {
|
|||||||
|
|
||||||
|
|
||||||
public static POITextExtractor createExtractor(File f) throws IOException, InvalidFormatException, OpenXML4JException, XmlException {
|
public static POITextExtractor createExtractor(File f) throws IOException, InvalidFormatException, OpenXML4JException, XmlException {
|
||||||
InputStream inp = new PushbackInputStream(
|
InputStream inp = null;
|
||||||
|
try {
|
||||||
|
inp = new PushbackInputStream(
|
||||||
new FileInputStream(f), 8);
|
new FileInputStream(f), 8);
|
||||||
|
|
||||||
if(POIFSFileSystem.hasPOIFSHeader(inp)) {
|
if(POIFSFileSystem.hasPOIFSHeader(inp)) {
|
||||||
return createExtractor(new POIFSFileSystem(inp));
|
return createExtractor(new POIFSFileSystem(inp));
|
||||||
}
|
}
|
||||||
if(POIXMLDocument.hasOOXMLHeader(inp)) {
|
if(POIXMLDocument.hasOOXMLHeader(inp)) {
|
||||||
inp.close();
|
|
||||||
return createExtractor(OPCPackage.open(f.toString()));
|
return createExtractor(OPCPackage.open(f.toString()));
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Your File was neither an OLE2 file, nor an OOXML file");
|
throw new IllegalArgumentException("Your File was neither an OLE2 file, nor an OOXML file");
|
||||||
|
} finally {
|
||||||
|
if(inp != null) inp.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static POITextExtractor createExtractor(InputStream inp) throws IOException, InvalidFormatException, OpenXML4JException, XmlException {
|
public static POITextExtractor createExtractor(InputStream inp) throws IOException, InvalidFormatException, OpenXML4JException, XmlException {
|
||||||
|
Loading…
Reference in New Issue
Block a user