RFR: 6244047: impossible to specify directories to logging FileHandler unless they exist (original) (raw)

Alan Bateman Alan.Bateman at oracle.com
Tue Nov 13 12:08:24 UTC 2012


On 12/11/2012 23:22, Jim Gish wrote:

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(), CREATENEW, WRITE); //fc = lockStream.getChannel(); CREATE rather than CREATE_NEW so that it doesn't fail if the lock file already exists. Although it's just a lock file then I think it would be impolite to truncate it.

You could use Paths.get(lockFileName)rather than new File(lockFileName).toPath() here but either is fine.

-Alan.



More information about the core-libs-dev mailing list