[
https://issues.apache.org/jira/browse/PDFBOX-382?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andreas Lehmkühler updated PDFBOX-382:
--------------------------------------
Priority: Minor (was: Major)
Affects Version/s: (was: 0.7.3)
0.8.0-incubator
Fix Version/s: (was: 0.7.3)
Changed priority to minor, affected version to 0.8.0 and deleted fixed version
> 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.8.0-incubator
> Environment: OS X 10.5.5, Java 1.5.0_16
> Reporter: Norman Gray
> Priority: Minor
> 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.