Should it be UnsupportedOppException or IOException for writing named attr to a link file without following it(Windows Vista)??
Alan Bateman
Alan.Bateman at Sun.COM
Mon Jun 9 07:10:14 PDT 2008
Rajendra Gutupalli wrote:
> Hi Alan,
>
> When I tried to write a named attribute to a link file in Windows
> Vista without following it, NamedAttributeView#write() throws
> IOException where as in Linux and Solaris the write() method
> throws UnsupportedOperationException for the same. Could you please
> tell me what should the method write() throw in case of Windows Vista
> when we don't follow a link.
> (Spec says for write method "UnsupportedOperationException: If not
> following links, the file is a link, and the implementation does not
> support accessing named attributes of a symbolic link" )
> Please see the exceptions I got in Windows Vista and Linux.
>
> <Windows Vista>
> Exception in thread "main" java.io.IOException: File is reparse point
> at
> sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:75)
>
> at
> sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
>
> at
> sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
>
> at
> sun.nio.fs.WindowsNamedAttributeView.write(WindowsNamedAttributeView.java:271)
>
> at Adhoc.NamedTest.main(NamedTest.java:19)
> </Vista>
>
UOE would be the correct exception but in this case there shouldn't be
any exception because, strange as it may be, NTFS allows sym links
(which are a type of reparse point) to have named streams. So this is a
bug, and as it happens, is exactly the same reason why you can't write a
directory's named attributes. The broken code arises because we open the
unnamed stream before the named stream to ensure a reasonable error in
the event that the unnamed stream doesn't exist (or is not accessible).
I've fixed it in my repository so will be in the next build. Thanks, as
always, for bashing on specific areas to find problems like this.
-Alan.
More information about the nio-dev
mailing list