Skip to content

rspec related out of bounds array access in multi-character string splitting #218

@slippycheeze

Description

@slippycheeze

Using this code under rspec causes an Java::JavaLang::ArrayIndexOutOfBoundsException under JRuby 1.6.7.2 and JRuby 1.7.0.preview1:

# rspec -fd test.rb
# test.rb
describe "JRuby and RSpec" do
  it "should not explode" do
    "foo#{"\n\n"}".lines("\n\n").map(&:to_s)
  end

  it "should also not explode" do
    ("foo" + "\n\n").lines("\n\n").map(&:to_s)
  end
end

It looks like some oddity triggered by using string interpolation / extension and multi-character separators. You can trigger the same thing by replacing .map(&:to_s) with a block: {|_|}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions