Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All RubyFileTest methods have a race condition #1950

Closed
enebo opened this issue Sep 4, 2014 · 2 comments
Closed

All RubyFileTest methods have a race condition #1950

enebo opened this issue Sep 4, 2014 · 2 comments
Milestone

Comments

@enebo
Copy link
Member

@enebo enebo commented Sep 4, 2014

The logic in all these methods is 'file.exists() && file.isFoo()' . If the file is removed between these two operation an exception will be raised from methods where no exceptions should be raised.

@enebo enebo added this to the JRuby 1.7.16 milestone Sep 4, 2014
@chrisseaton
Copy link
Contributor

@chrisseaton chrisseaton commented Sep 5, 2014

By isFoo do you mean things like isFile and isDirectory? I think these implicitly include exists() don't they? isDirectory on something that doesn't exist returns false:

irb(main):001:0> java.io.File.new("doesnotexist").isDirectory()
=> false

So can't you just drop the first test? And is there a race condition anyway as I don't think any of the isFoo methods throw exceptions, do they?

@enebo
Copy link
Member Author

@enebo enebo commented Sep 5, 2014

@chrisseaton I have a local branch with all of this fixed. I just have a few failing tests. I just recorded the issue so it will be displayed in our release notes.

And removing exists() is not quite enough because the stat() was raising if the file did not exist. I converted stat() on FileResource to return null on inabiltiy to stat()

@enebo enebo closed this in f607e53 Sep 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants