[ https://issues.apache.org/jira/browse/PDFBOX-6075?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18022609#comment-18022609 ]
JIANG LIGUO commented on PDFBOX-6075: ------------------------------------- [~tilman] right, calling close() twice should be harmless, but in some complex situation, actually there is no clear way to know if the stream is closed. Especially when there are many nesting levels of method calls. It would be better to have a method to determine whether a stream is closed, to let the programmer know whether the current stream is closed, or to call the close() method again without throwing a null pointer exception, and to be compatible with older versions of the writing. > 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: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org