[ https://issues.apache.org/jira/browse/PDFBOX-6016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17956602#comment-17956602 ]
Pavel commented on PDFBOX-6016: ------------------------------- Great, thank you very much :-) > PreflightParser doesn't close RandomAccessReadBufferedFile causing file locks > on Windows > ---------------------------------------------------------------------------------------- > > Key: PDFBOX-6016 > URL: https://issues.apache.org/jira/browse/PDFBOX-6016 > Project: PDFBox > Issue Type: Bug > Components: Preflight > Affects Versions: 3.0.5 PDFBox > Reporter: Pavel > Priority: Major > Fix For: 3.0.6 PDFBox > > > I've occasionally stumbled upon a problem with locked files on Windows - a > validated with PreflightParser PDF file cannot be deleted under Windows for a > certain amount of time, causing or sorts of troubles. After investigating the > problem, I've noticed, that PreflightParser creates > RandomAccessReadBufferedFile and passes it to super class into the protected > "source" field. This source field is never closed in either PreflightParser > or any of its parents. I think it is a duty of the caller to close it, so > PreflightParser should have closed it. Perhaps it is a good idea to implement > Closeable as well. My prove-of-concept class solved the original problem of > files being locked > {code:java} > class MyPreflightParser extends PreflightParser implements Closeable > { > public MyPreflightParser(File file) throws IOException > { > super(file); > } > @Override > public void close() throws IOException > { > IOUtils.closeQuietly(super.source); > } > } > {code} -- 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