[
https://issues.apache.org/jira/browse/PDFBOX-6075?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18022409#comment-18022409
]
Tilman Hausherr commented on PDFBOX-6075:
-----------------------------------------
Is this something that actually happened, or is this something that you
noticed? Calling close() twice should be harmless. There is a test that does it:
{code:java}
@Test
void testCloseContract() throws IOException
{
try (PDDocument doc = new PDDocument())
{
PDPage page = new PDPage();
doc.addPage(page);
PDPageContentStream contentStream = new PDPageContentStream(doc,
page, AppendMode.OVERWRITE, true);
contentStream.close();
contentStream.close();
}
}
{code}
> PDPageContentStream.close() method cannot execute repeatedly
> ------------------------------------------------------------
>
> Key: PDFBOX-6075
> URL: https://issues.apache.org/jira/browse/PDFBOX-6075
> Project: PDFBox
> Issue Type: Bug
> Components: PDModel
> Affects Versions: 3.0.3 PDFBox
> Reporter: JIANG LIGUO
> Priority: Minor
> Attachments: image-2025-09-24-18-08-15-654.png,
> image-2025-09-24-18-14-47-166.png
>
> Original Estimate: 504h
> Remaining Estimate: 504h
>
>
> the method PDPageContentStream.close() exists a logic to check for
> null/empty in version 2.0.33.
> !image-2025-09-24-18-08-15-654.png|width=456,height=285!
>
> but in version 3.0.3,this method was migrated to parent class
> PDPageContentStream, and the logic to check for null/empty was removed.
> !image-2025-09-24-18-14-47-166.png|width=660,height=149!
>
> then I failed to call PDPageContentStream.close() second, it raise NPE.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]