RFR: 6244047: impossible to specify directories to logging FileHandler unless they exist
Jim Gish
jim.gish at oracle.com
Wed Nov 14 21:54:48 UTC 2012
On 11/14/2012 04:38 PM, Alan Bateman wrote:
> On 14/11/2012 20:56, Jim Gish wrote:
>> Check out the latest, please --
>> http://cr.openjdk.java.net/~jgish/Bug6244047-FileHandler-CheckLockLocation/
>> <http://cr.openjdk.java.net/%7Ejgish/Bug6244047-FileHandler-CheckLockLocation/>
>> -- If it's ok, please push it or let me know who to have do it?
> I think it's okay except that you don't need to catch IOException,
> simply catching FileAlreadyExistsException exception should do it. If
> you agree then update the patch and I can push it for you.
But of course. Sorry I missed the obvious. Just peeling the onion when
I could have taken a bite :-) Fixed, and updated.
>
>> :
>>
>> BTW I was expecting that NotDirectoryException would be thrown.
>> However, sun.nio.fs.UnixException does not translate an error code 20
>> (UnixConstants.ENOTDIR) to NotDirectoryException, even though it
>> could. Perhaps we should fix that, unless you see a reason not to.
>> I'll check the history, bug reports, etc. and bring it up on nio-dev
>> unless you know off the top of your head why we're not checking for
>> ENOTDIR error code.
> NotDirectoryException is for the case where you attempt do something
> specific to a directory but the file isn't a directory. There is
> special handing in newDirectoryStream for this.
>
Exactly -- that's my point. This is one of those cases. You're trying
to create a new file in a directory, but the file you specified isn't a
directory - it's a plain file. The error code coming back is ENOTDIR
and so what you get is the more general FileSystemException with "Not a
directory" as the error message, when in fact, we could throw
NotDirectoryException if we'd simply check for errno of ENOTDIR in the
first place along with the other checks being done in UnixException
translateToIOException(File,String).
> -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