You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Lonzak (JIRA)" <ji...@apache.org> on 2019/03/22 10:33:00 UTC
[jira] [Created] (PDFBOX-4493) InputStream not closed after reading
Lonzak created PDFBOX-4493:
------------------------------
Summary: 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
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