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

Thomas Modeneis updated PDFBOX-382:
-----------------------------------

    Attachment: ThomasTest.java

Hey Norman, 

Thanks for your answer...

So, ive made some simple example to reproduce the bug... and you can execute it 
on your eclipse to reproduce the reported bug.

Regards,

Thomas Modeneis.



> PDDocument apparently unclosed even after calling close()
> ---------------------------------------------------------
>
>                 Key: PDFBOX-382
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-382
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 0.7.3
>         Environment: OS X 10.5.5, Java 1.5.0_16
>            Reporter: Norman Gray
>             Fix For: 0.7.3
>
>         Attachments: ThomasTest.java
>
>
> I can open a PDDocument, extract information from it, and then close it.  
> However if I then open another PDDocument, I get an exception 'You did not 
> close the PDF Document'.  Looking at the relevant code in incubator svn, 
> nothing stands out as being obviously wrong.
> To reproduce:
> % cat PDFBoxBugReduction.java 
> import org.pdfbox.pdmodel.PDDocument;
> import org.pdfbox.pdmodel.PDDocumentInformation;
> public class PDFBoxBugReduction {
>     public static void main(String[] args) {
>         for (String s : args) {
>             PDFBoxBugReduction fi = new PDFBoxBugReduction(s);
>             System.err.println("File " + s);
>         }
>     }
>     
>     public PDFBoxBugReduction(String filename) {
>         PDDocument doc = null;
>         try {
>             try {
>                 doc = new PDDocument().load(filename);
>                 PDDocumentInformation info = doc.getDocumentInformation();
>             } finally {
>                 if (doc != null) {
>                     System.err.println("Closing document " + filename + 
> "...");
>                     org.pdfbox.cos.COSDocument cos = doc.getDocument();
>                     cos.close();
>                     System.err.println("Closed " + cos);
>                     doc.close();
>                 }
>                 
>             }
>             
>         } catch (java.io.IOException e) {
>             System.err.println("IOException=" + e);
>             System.exit(1);
>         }
>     }
> }
> % java -version              
> java version "1.5.0_16"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)
> Java HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)
> % javac -cp PDFBox-0.7.3.jar PDFBoxBugReduction.java                      
> % java -cp PDFBox-0.7.3.jar:. PDFBoxBugReduction ../part1.pdf ../part2.pdf
> Closing document ../part1.pdf...
> Closed org.pdfbox.cos.cosdocum...@2a54f9
> File ../part1.pdf
> java.lang.Throwable: Warning: You did not close the PDF Document
>       at org.pdfbox.cos.COSDocument.finalize(COSDocument.java:418)
>       at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
>       at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
>       at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
>       at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)
> Closing document ../part2.pdf...
> Closed org.pdfbox.cos.cosdocum...@6672d6
> File ../part2.pdf
> % 
> Oddly, replacing
>  
>     doc = new PDDocument().load(filename);
> by
>     doc = new PDDocument();
>     doc.load(filename);
> ...makes the problem go away.  Is the wrong thing perhaps being returned by 
> load()?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to