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

JRuby 1.7.12: File.read("") throws Java ArrayIndexOutOfBoundsException #1726

Closed
aetherknight opened this issue Jun 4, 2014 · 1 comment
Closed
Milestone

Comments

@aetherknight
Copy link

@aetherknight aetherknight commented Jun 4, 2014

When I perform a File.read('') with JRuby 1.7.12, JRuby raises a Java ArrayIndexOutOfBoundsException instead of a Ruby Errno::ENOENT exception.

Expected behavior

$ ruby -e 'File.read("")'
-e:1:in `read': No such file or directory -  (Errno::ENOENT)
    from -e:1:in `<main>'

This is true with both MRI 1.9.3 and 2.0.0:

$ ruby --version
ruby 1.9.3p545 (2014-02-24 revision 45159) [x86_64-darwin13.2.0]

$ ruby --version
ruby 2.0.0p451 (2014-02-24 revision 45167) [x86_64-darwin12.5.0]

Observed behavior

$ jruby -e 'File.read("")'
EncodingUtils.java:597:in `encAscget': java.lang.ArrayIndexOutOfBoundsException: 0
    from RubyIO.java:3841:in `checkPipeCommand'
    from RubyIO.java:3829:in `ioOpen'
    from RubyIO.java:3796:in `openKeyArgs'
    from RubyIO.java:3776:in `read19'
    from RubyIO.java:3955:in `read19'
    from RubyIO$INVOKER$s$0$3$read19.gen:-1:in `call'
    from DynamicMethod.java:210:in `call'
    from DynamicMethod.java:206:in `call'
    from CachingCallSite.java:326:in `cacheAndCall'
    from CachingCallSite.java:170:in `call'
    from -e:1:in `__file__'
    from -e:-1:in `load'
    from Ruby.java:811:in `runScript'
    from Ruby.java:804:in `runScript'
    from Ruby.java:673: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'

Version details:

$ jruby --version
jruby 1.7.12 (1.9.3p392) 2014-04-15 643e292 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_55-b13 [darwin-x86_64]

$ java -version
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)
@aetherknight
Copy link
Author

@aetherknight aetherknight commented Jun 4, 2014

I just tested the current tip of the jruby-1_7 branch (currently 61b6673), and the issue exists there as well:

$ bin/jruby -e 'File.read("")'
EncodingUtils.java:597:in `encAscget': java.lang.ArrayIndexOutOfBoundsException: 0
    from RubyIO.java:3843:in `checkPipeCommand'
    from RubyIO.java:3831:in `ioOpen'
    from RubyIO.java:3798:in `openKeyArgs'
    from RubyIO.java:3778:in `read19'
    from RubyIO.java:3957:in `read19'
    from RubyIO$INVOKER$s$0$3$read19.gen:-1:in `call'
    from DynamicMethod.java:210:in `call'
    from DynamicMethod.java:206:in `call'
    from CachingCallSite.java:326:in `cacheAndCall'
    from CachingCallSite.java:170:in `call'
    from -e:1:in `__file__'
    from -e:-1:in `load'
    from Ruby.java:854:in `runScript'
    from Ruby.java:847:in `runScript'
    from Ruby.java:716:in `runNormally'
    from Ruby.java:565: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'
lucasallan added a commit to lucasallan/jruby that referenced this issue Jun 8, 2014
…e is an empty String.

File.read it's currently raising EncodingUtils.java:597:in `encAscget':
java.lang.ArrayIndexOutOfBoundsException: 0

But it should raise an Errno::ENOENT to keep the MRI compatibility.
lucasallan added a commit to lucasallan/jruby that referenced this issue Jun 8, 2014
…e is an empty String.

File.read it's currently raising EncodingUtils.java:597:in `encAscget':
java.lang.ArrayIndexOutOfBoundsException: 0

But it should raise an Errno::ENOENT to keep the MRI compatibility.
enebo added a commit that referenced this issue Jun 14, 2014
[GH-1726] - File.read should raise an Errno::ENOENT when the file is an empty String
@enebo enebo added this to the JRuby 1.7.13 milestone Jun 14, 2014
@enebo enebo closed this Jun 14, 2014
k77ch7 added a commit to k77ch7/jruby that referenced this issue Nov 27, 2014
enebo added a commit that referenced this issue Dec 1, 2014
Fix GH-1726 on master
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.

2 participants