mirror of https://github.com/apache/poi.git
close input streams for parts
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1896464 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
90319df180
commit
2996f82e98
|
@ -36,6 +36,7 @@ import javax.xml.crypto.URIReference;
|
|||
import javax.xml.crypto.URIReferenceException;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -81,7 +82,7 @@ public class OOXMLURIDereferencer implements URIDereferencer {
|
|||
return baseUriDereferencer.dereference(uriReference, context);
|
||||
}
|
||||
|
||||
InputStream dataStream;
|
||||
InputStream dataStream = null;
|
||||
try {
|
||||
dataStream = part.getInputStream();
|
||||
|
||||
|
@ -99,6 +100,7 @@ public class OOXMLURIDereferencer implements URIDereferencer {
|
|||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
IOUtils.closeQuietly(dataStream);
|
||||
throw new URIReferenceException("I/O error: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,8 +68,9 @@ public class XSSFBSharedStringsTable implements SharedStrings {
|
|||
// Some workbooks have no shared strings table.
|
||||
if (parts.size() > 0) {
|
||||
PackagePart sstPart = parts.get(0);
|
||||
|
||||
readFrom(sstPart.getInputStream());
|
||||
try (InputStream stream = sstPart.getInputStream()) {
|
||||
readFrom(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,9 @@ public class ReadOnlySharedStringsTable extends DefaultHandler implements Shared
|
|||
// Some workbooks have no shared strings table.
|
||||
if (parts.size() > 0) {
|
||||
PackagePart sstPart = parts.get(0);
|
||||
readFrom(sstPart.getInputStream());
|
||||
try (InputStream stream = sstPart.getInputStream()) {
|
||||
readFrom(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,9 @@ public class XSSFBReader extends XSSFReader {
|
|||
}
|
||||
PackagePartName commentsName = PackagingURIHelper.createPartName(comments.getTargetURI());
|
||||
PackagePart commentsPart = sheetPkg.getPackage().getPart(commentsName);
|
||||
return new XSSFBCommentsTable(commentsPart.getInputStream());
|
||||
try (InputStream stream = commentsPart.getInputStream()) {
|
||||
return new XSSFBCommentsTable(stream);
|
||||
}
|
||||
}
|
||||
} catch (InvalidFormatException | IOException e) {
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue