[ 
https://issues.apache.org/jira/browse/PDFBOX-3388?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15347880#comment-15347880
 ] 

Tilman Hausherr commented on PDFBOX-3388:
-----------------------------------------

Obviously, the finalize() method does the closing so you don't have to. 
Finalize is called when the object is no longer referenced. If you get the 
debug message it means that it has been closed. If there would be an object 
despite everything else closed by you then it would be suspicious.

{quote}
But if a reference to the object remains in memory then gc won't know to
call finalize and hence my code won't close the reference . Am I right?
{quote}
Yes. But to prove this you would have to bring up code that produces this, we 
can't help you without. The best is to take your own code, and then to delete 
as much as possible as long you have the effect. The more complex your code is, 
the more it is likely that yourself are still holding some reference to an 
object.

> PDFTextStripper - ScratchFileBuffer not closed!
> -----------------------------------------------
>
>                 Key: PDFBOX-3388
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3388
>             Project: PDFBox
>          Issue Type: Bug
>            Reporter: Roman Pichlik
>         Attachments: CloseablePDFParser.java, PDFStripperTest.java, test.pdf
>
>
> _PDFTextStripper_ or inherently used classes probably do not close all opened 
> streams under all circumstances. You can reproduce that by the following 
> snippet of code and the attached PDF file.
> {code}
> try (RandomAccessBuffer rab = new RandomAccessBuffer(is)) {
>             PDFParser parser = new PDFParser(rab);
>             parser.parse();
>             try (COSDocument cosDoc = parser.getDocument();PDDocument pdDoc = 
> new PDDocument(cosDoc);){
>                 PDFTextStripper pdfStripper = new PDFTextStripper();
>                 pdfStripper.getText(pdDoc);
>             }
>         } catch (IOException e) {
>             throw new RuntimeException(e);
>         }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to