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

File::mtime causes errors when file path contains non-english chars #2365

Closed
headius opened this issue Dec 29, 2014 · 2 comments
Closed

File::mtime causes errors when file path contains non-english chars #2365

headius opened this issue Dec 29, 2014 · 2 comments

Comments

@headius
Copy link
Member

@headius headius commented Dec 29, 2014

From http://jira.codehaus.org/browse/JRUBY-7192

Original Report

Ran into another bug while trying to get rails testsuite running on JRuby. Like, previous one this too is caused by non-english chars.

_Problem_
when [StaticTests#test_served_static_file_with_non_english_filename|https://github.com/rails/rails/blob/master/actionpack/test/dispatch/static_test.rb#L40] is run, it raises the following Exception

Buffer.java:236:in `position': java.lang.IllegalArgumentException
    from CharSequenceParameterConverter.java:125:in `toNative'
    from null:-1:in `__xstat64'
    from LinuxPOSIX.java:116:in `stat'
    from CheckedPOSIX.java:261:in `stat'
    from LazyPOSIX.java:263:in `stat'
    from RubyFileStat.java:160:in `setup'
    from RubyFileStat.java:92:in `newFileStat'
    from Ruby.java:3180:in `newFileStat'
    from RubyFile.java:913:in `mtime'
    from RubyFile$INVOKER$s$1$0$mtime.gen:-1:in `call'
    from CachingCallSite.java:326:in `cacheAndCall'
    from CachingCallSite.java:170:in `call'
    from CallOneArgNode.java:57:in `interpret'
    from FCallOneArgNode.java:36:in `interpret'
    from NewlineNode.java:105:in `interpret'
    from RootNode.java:129:in `interpret'
    from ASTInterpreter.java:121:in `INTERPRET_ROOT'
    from Ruby.java:838:in `runInterpreter'
    from Ruby.java:846:in `runInterpreter'
    from Ruby.java:677:in `runNormally'
    from Ruby.java:522:in `runFromMain'
    from Main.java:395:in `doRunFromMain'
    from Main.java:290:in `internalRun'
    from Main.java:217:in `run'
    from Main.java:197:in `main'

I looked into this further and managed to isolate the issue to this line of [Rack::File|https://github.com/rack/rack/blob/master/lib/rack/file.rb#L67]

last_modified = F.mtime(@path)

With this new information, I was able to reproduce this behaviour directly from command-line

$ jruby -e'puts File.mtime "/home/gaurish/code/repo/rails/actionpack/test/fixtures/public/foo/�ん���.html"'
Buffer.java:236:in `position': java.lang.IllegalArgumentException
....
....

For the intended/expected behaviour it should return DateTime Object as seen below on MRI

$ ruby -e'puts File.mtime "/home/gaurish/code/repo/rails/actionpack/test/fixtures/public/foo/�ん���.html"'
2013-08-03 15:49:14 +0530

Update, if above the chars are not being displayed correctly: the file resides [here|https://github.com/rails/rails/blob/master/actionpack/test/fixtures/public/foo/%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF.html]

@headius
Copy link
Member Author

@headius headius commented Dec 29, 2014

@kares
Copy link
Member

@kares kares commented Mar 1, 2018

kares@sputnik:~/workspace/oss/jruby$ touch tmp/�ん���.html

kares@sputnik:~/workspace/oss/jruby$ ls tmp/
�ん���.html 

kares@sputnik:~/workspace/oss/jruby$ ruby -e'puts File.mtime "tmp/�ん���.html"'
2018-03-01 16:10:53 +0100

... working like a charm 🎉

@kares kares closed this Mar 1, 2018
@kares kares added this to the Invalid or Duplicate milestone Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants