Discussion:
[jruby-dev] [jira] (JRUBY-7192) File::mtime cause Java IllegalArgumentException when file path contains non-english chars
(too old to reply)
Gaurish Sharma (JIRA)
2013-08-03 10:52:52 UTC
Permalink
<style>
/* Changing the layout to use less space for mobiles */
@media screen and (max-device-width: 480px), screen and (-webkit-min-device-pixel-ratio: 2) {
#email-body { min-width: 30em !important; }
#email-page { padding: 8px !important; }
#email-banner { padding: 8px 8px 0 8px !important; }
#email-avatar { margin: 1px 8px 8px 0 !important; padding: 0 !important; }
#email-fields { padding: 0 8px 8px 8px !important; }
#email-gutter { width: 0 !important; }
}
</style>
<div id="email-body">
<table id="email-wrap" align="center" border="0" cellpadding="0" cellspacing="0" style="background-color:#f0f0f0;color:#000000;width:100%;">
<tr valign="top">
<td id="email-page" style="padding:16px !important;">
<table align="center" border="0" cellpadding="0" cellspacing="0" style="background-color:#ffffff;border:1px solid #bbbbbb;color:#000000;width:100%;">
<tr valign="top">
<td bgcolor="#ffffff" style="background-color:#ffffff;color:#00AA00;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;line-height:1;"><img src="Loading Image..." alt="" style="vertical-align:top;" /></td>
</tr><tr valign="top">
<td id="email-banner" style="padding:32px 32px 0 32px;">




<table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;">
<tr valign="top">
<td style="color:#505050;font-family:Arial,FreeSans,Helvetica,sans-serif;padding:0;">
<img id="email-avatar" src="https://jira.codehaus.org/secure/useravatar?avatarId=10232" alt="" height="48" width="48" border="0" align="left" style="padding:0;margin: 0 16px 16px 0;" />
<div id="email-action" style="padding: 0 0 8px 0;font-size:12px;line-height:18px;">
<a class="user-hover" rel="gaurish" id="email_gaurish" href="https://jira.codehaus.org/secure/ViewProfile.jspa?name=gaurish" style="color:#005500;">Gaurish Sharma</a>
created <img src="Loading Image..." height="16" width="16" border="0" align="absmiddle" alt="Bug"> <a style='color:#005500;text-decoration:none;' href='https://jira.codehaus.org/browse/JRUBY-7192'>JRUBY-7192</a>
</div>
<div id="email-summary" style="font-size:16px;line-height:20px;padding:2px 0 16px 0;">
<a style='color:#005500;text-decoration:none;' href='https://jira.codehaus.org/browse/JRUBY-7192'><strong>File::mtime cause Java IllegalArgumentException when file path contains non-english chars</strong></a>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td id="email-fields" style="padding:0 32px 32px 32px;">
<table border="0" cellpadding="0" cellspacing="0" style="padding:0;text-align:left;width:100%;" width="100%">
<tr valign="top">
<td id="email-gutter" style="width:64px;white-space:nowrap;"></td>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Issue Type:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<img src="https://jira.codehaus.org/images/icons/issuetypes/bug.png" height="16" width="16" border="0" align="absmiddle" alt="Bug"> Bug
</td>
</tr> <tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Affects Versions:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
JRuby 1.7.4 </td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Assignee:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
Unassigned </td>
</tr> <tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Components:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
Core Classes/Modules </td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Created:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
03/Aug/13 5:52 AM
</td>
</tr> <tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Description:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<p style='margin-top:0;margin-bottom:10px;'>Ran into another bug while trying to get rails testsuite running on JRuby. Like, previous one this too is caused by non-english chars. </p>

<h2><a name="Problem"></a>Problem</h2>
<p style='margin-top:0;margin-bottom:10px;'>when <a href="https://github.com/rails/rails/blob/master/actionpack/test/dispatch/static_test.rb#L40" class="external-link">StaticTests#test_served_static_file_with_non_english_filename</a> is run, it raises the following Exception</p>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>IllegalArgumentException</b></div><div class="codeContent panelContent">
<pre class="code-java">
Buffer.java:236:in `position': java.lang.IllegalArgumentException
from CharSequenceParameterConverter.java:125:in `toNative'
from <span class="code-keyword">null</span>:-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'
</pre>
</div></div>

<p style='margin-top:0;margin-bottom:10px;'>I looked into this further and managed to isolate the issue to this line of <a href="https://github.com/rack/rack/blob/master/lib/rack/file.rb#L67" class="external-link">Rack::File</a></p>

<p style='margin-top:0;margin-bottom:10px;'>last_modified = F.mtime(@path).httpdate</p>

<p style='margin-top:0;margin-bottom:10px;'>With this new information, I was able to reproduce this behaviour directly from command-line</p>

<p style='margin-top:0;margin-bottom:10px;'>$ jruby -e'puts File.mtime "/home/gaurish/code/repo/rails/actionpack/test/fixtures/public/foo/ã&ldquo;ã‚&ldquo;にちは.html"'</p>

<p style='margin-top:0;margin-bottom:10px;'>For the intended/expected behaviour it should return DateTime Object as seen below on MRI</p>

<p style='margin-top:0;margin-bottom:10px;'>$ ruby -e'puts File.mtime "/home/gaurish/code/repo/rails/actionpack/test/fixtures/public/foo/ã&ldquo;ã‚&ldquo;にちは.html"'<br/>
2013-08-01 18:39:02 +0530</p>

</td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Project:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<a style="color:#005500;" href="https://jira.codehaus.org/browse/JRUBY">JRuby</a>
</td>
</tr> <tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Priority:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<img src="Loading Image..." height="16" width="16" border="0" align="absmiddle" alt="Major"> Major
</td>
</tr>
<tr valign="top">
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 10px 10px 0;white-space:nowrap;">
<strong style="font-weight:normal;color:#505050;">Reporter:</strong>
</td>
<td style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 10px 0;width:100%;">
<a class="user-hover" rel="gaurish" id="email_gaurish" href="https://jira.codehaus.org/secure/ViewProfile.jspa?name=gaurish" style="color:#005500;">Gaurish Sharma</a>
</td>
</tr>


</table>
</td>
</tr>
</table>
</td>
</tr>













</table>
</td><!-- End #email-page -->
</tr>
<tr valign="top">
<td style="color:#505050;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:10px;line-height:14px;padding: 0 16px 16px 16px;text-align:center;">
This message is automatically generated by JIRA.<br />
If you think it was sent incorrectly, please contact your JIRA administrators<br />
For more information on JIRA, see: <a style='color:#005500;' href='http://www.atlassian.com/software/jira'>http://www.atlassian.com/software/jira</a>
</td>
</tr>
</table><!-- End #email-wrap -->
</div><!-- End #email-body -->

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Loading...