[
https://issues.apache.org/jira/browse/PDFBOX-6016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17956599#comment-17956599
]
Tilman Hausherr commented on PDFBOX-6016:
-----------------------------------------
I think I got it. The source is never passed to PDDocument, the bug is here in
the parser, the source isn't passed to the PDDocument:
{code}
protected PDDocument createDocument() throws IOException
{
preflightDocument = new PreflightDocument(document, format, config);
return preflightDocument;
}
{code}
> 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: [email protected]
For additional commands, e-mail: [email protected]