Jeroen Frijters wrote:
Dalibor Topic wrote:

Yeah, i can understand the inefficient part, as the same code is duplicated in two classes. Could you elaborate some more on the racy part?


If another application creates a directory after the check, but before
the file is created, an incorrect error is thrown. So ideally the native
code that calls the platform file open API needs to handle this error
case.

Isn't that the case in any way, independently of the implementation strategy used? Unless a platform has an atomic 'check if dir and open' function call, there is always a time slice where some other application can do stuff that invalidates what we know.


Another strategy to implement this in the FileChannelImpl constructor would be to call open() first, and then to check whether what we have opened is a directory, and if it is one to call close() + throw FileNotFoundException in that case. Does that sound OK?

I can attach a patch, if you're interested.

cheers,
dalibor topic


_______________________________________________ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to