[ 
https://issues.apache.org/jira/browse/PDFBOX-2882?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14632894#comment-14632894
 ] 

John Hewson edited comment on PDFBOX-2882 at 7/19/15 6:40 PM:
--------------------------------------------------------------

There are still problems with the close logic.

{code}
public void close() throws IOException
{
    if (isClosed)
    {
        return;
    }

    isClosed = true;

    IOException ioexc = null;
    
    synchronized (ioLock)
    {
        ....
{code}

isClosed is being used in a check-and-set without any synchronisation or 
atomicity. If two threads call close() at the same time, both will try to close 
and delete the file. (As previously mentioned, there's no need to track 
isClosed anyway).

This problem applies to checkClosed() too, which can return true during close() 
being called, because of the problem described above. That means that any 
reads/writes which checkClosed() is protecting could occur after close() has 
run. (Reads against raf will throw an IOException anyway, as mentioned, so 
checkClosed() in that case is redundant).


was (Author: jahewson):
There are still problems with the close logic.

{code}
public void close() throws IOException
{
    if (isClosed)
    {
        return;
    }

    isClosed = true;

    IOException ioexc = null;
    
    synchronized (ioLock)
    {
        ....
{code}

isClosed is being used in a check-and-set without any synchronisation or 
atomicity. If two threads call close() at the same time, both will try to close 
and delete the file. (As previously mentioned, there's no need to track 
isClosed anyway).

This problem applies to checkClosed() too, which can return true during close() 
being called, because of the problem described above. That means that any 
reads/writes which checkClosed() is protecting could occur after close() has 
run.

> Improve performance when using scratch file
> -------------------------------------------
>
>                 Key: PDFBOX-2882
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2882
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: Parsing
>    Affects Versions: 2.0.0
>            Reporter: Timo Boehme
>            Assignee: Timo Boehme
>            Priority: Minor
>             Fix For: 2.0.0
>
>         Attachments: ScratchFile.java, ScratchFileBuffer.java
>
>
> The current scratch file implementation uses many direct I/O calls which 
> slows down parsing compared with in-memory scratch buffer considerably.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to