Pavel created PDFBOX-6016:
-----------------------------
Summary: 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
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 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]