Gilbert created PDFBOX-5013:
-------------------------------

             Summary: Java Runtime Finalizer closes all COSDocument-Objects no 
mater if they are still being used or not
                 Key: PDFBOX-5013
                 URL: https://issues.apache.org/jira/browse/PDFBOX-5013
             Project: PDFBox
          Issue Type: Bug
          Components: Writing
    Affects Versions: 2.0.21, 2.0.20
         Environment: SpringBoot 
            Reporter: Gilbert


I am running a spring boot based microservice that creates pdf's for a mimaki 
digital printer.

Every pdf contains multiple type labels with an individual datamatrix code on 
it, which I have been creating with PDFbox.

A single run for a job takes about 3-4 minutes. The service is running 
flawlessly for hours but sometimes during a large job the following Exception 
is thrown while writing the resulting pdf to disc.

Caused by: java.io.IOException: COSStream has been closed and cannot be read. 
Perhaps its enclosing PDDocument has been closed?
 at org.apache.pdfbox.cos.COSStream.checkClosed(COSStream.java:83)
 at org.apache.pdfbox.cos.COSStream.createRawInputStream(COSStream.java:133)
 at org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1217)
 at org.apache.pdfbox.cos.COSStream.accept(COSStream.java:404)
 at org.apache.pdfbox.cos.COSObject.accept(COSObject.java:158)
 at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:524)
 at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObjects(COSWriter.java:462)
 at org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:446)
 at org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1111)
 at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:449)
 at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1384)
 at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1271)
 at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1350)
 at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1321)
 at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1309)
 at 
de.dehn.middleware.service.PDFService$PDFCreatorCallable.save(PDFService.java:458)

I have tracked it down and found out that the Java Finalizer calls the 
finalize() Method on all COSDocument Objects and closes them forcefully no 
matter I've they are still being used or not. 

 

 

 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to