[
https://issues.apache.org/jira/browse/PDFBOX-4493?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tilman Hausherr resolved PDFBOX-4493.
-------------------------------------
Resolution: Fixed
Assignee: Tilman Hausherr
Fix Version/s: 3.0.0 PDFBox
2.0.15
Done. Please don't close (resolve only of fixed issues, closing for these is
done at release time).
> InputStream not closed after reading
> -------------------------------------
>
> Key: PDFBOX-4493
> URL: https://issues.apache.org/jira/browse/PDFBOX-4493
> Project: PDFBox
> Issue Type: Bug
> Components: Documentation
> Affects Versions: 2.0.14
> Reporter: Lonzak
> Assignee: Tilman Hausherr
> Priority: Major
> Labels: easyfix
> Fix For: 2.0.15, 3.0.0 PDFBox
>
>
> Loading a PDF document like this:
>
> {code:java}
> InputStream isPdfFile;
> PDDocument = PDDocument.load(isPdfFile);{code}
>
> Within the load(...) method the following is called:
>
> {code:java}
> public static PDDocument load(...){
> ...
> RandomAccessRead source = scratchFile.createBuffer(input);
> ...}{code}
> Then in the Scratchfile:
>
> {code:java}
> public RandomAccess createBuffer(InputStream input) throws IOException{
> ...
> while ((bytesRead = input.read(byteBuffer)) > -1)
> ...}{code}
> Now the stream is consumed but it is not closed. This is a potential resource
> leak since it could not be reused anyway. The stream should be closed. (If
> you do not want to close an outside stream then at least a java doc comment
> in the PDDocument should hint that the stream must be closed afterwards...)
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]