RFR: 8059269 - FileHandler may throw NPE if pattern is a simple name and the lock file already exists

Daniel Fuchs daniel.fuchs at oracle.com
Mon Sep 29 12:53:15 UTC 2014

On 29/09/14 13:42, Alan Bateman wrote:
> On 29/09/2014 09:51, Daniel Fuchs wrote:
>> The files created by the test (both log files and lock files) will be
>> removed by the finally block at lines 150 - 174 - so the test shouldn't
>> leave any files open (which I verified by running the test on a JDK that
>> does not have the fix).
> It's the lock files created at L233 & L234 that I'm wondering about.
> Suppose creating the second lock fails, that will leave the first lock
> file open (even if it removed).

Do you mean that calling delete() will not close the file?

The lock files created at lines 233-234 are those that
are declared at lines 127-130 and they will be deleted
at line 164.

But since all the test wants to do at lines 233-234 is to
create the files, then it could probably close them just
after creating them.
We don't need to leave the file descriptors open.
It's a good point.

- 233   FileChannel.open(Paths.get(file + ".lck"), CREATE_NEW, WRITE);
- 234   FileChannel.open(Paths.get(file + ".1.lck"), CREATE_NEW, WRITE);
+ 233   FileChannel.open(Paths.get(file + ".lck"), CREATE_NEW, WRITE)
+ 234  FileChannel.open(Paths.get(file + ".1.lck"), CREATE_NEW, WRITE)



-- daniel

> -Alan.

More information about the core-libs-dev mailing list