You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2019/03/30 06:36:03 UTC

[jira] [Reopened] (PDFBOX-4493) InputStream not closed after reading

     [ https://issues.apache.org/jira/browse/PDFBOX-4493?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tilman Hausherr reopened PDFBOX-4493:
-------------------------------------

> InputStream not closed after reading 
> -------------------------------------
>
>                 Key: PDFBOX-4493
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4493
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.14
>            Reporter: Lonzak
>            Priority: Major
>              Labels: easyfix
>
> 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: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org