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

Lonzak updated PDFBOX-4493:
---------------------------
    Comment: was deleted

(was: Yeah you are right. Still a small hint at the jdoc for us "forgetters" 
would be helpful ;) Can be closed then...)

> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to