RFR: 6244047: impossible to specify directories to logging FileHandler unless they exist

Jim Gish jim.gish at oracle.com
Mon Nov 12 23:22:47 UTC 2012


Which file(s) are you concerned about truncating/damaging?  The code I'm 
impacting is for creating a new lock file.  Where is the potential for 
truncating/damaging that you both are referring to?

Is this sufficient (plus the proper exception handling of course) ?

                     //lockStream = new FileOutputStream(lockFileName);
                     fc = FileChannel.open(new 
File(lockFileName).toPath(), CREATE_NEW, WRITE);
                     //fc = lockStream.getChannel();

Thanks,
    Jim

On 11/10/2012 05:54 AM, Alan Bateman wrote:
> On 09/11/2012 22:41, Jason Mehrens wrote:
>> Jim,
>>
>> You might just want to change the code to create and close a 
>> FileOutputStream in a way that doesn't truncate or damage the target 
>> file.  Or maybe use the NIO file code if that is possible.  See BUG 
>> ID 4420020.
>>
>> Jason
> I think so too. As it needs a FileChannel anyway, then it may be 
> simpler to just use FileChannel.open(lf, WRITE), that won't truncate 
> the file and will also throw a useful IOException in the event that it 
> fails. As there are specific IOException thrown for specific cases 
> then it may be possible to eliminate the loop completely for I/O error 
> cases.
>
> -Alan

-- 
Jim Gish | Consulting Member of Technical Staff | +1.781.442.0304
Oracle Java Platform Group | Core Libraries Team
35 Network Drive
Burlington, MA 01803
jim.gish at oracle.com




More information about the core-libs-dev mailing list