Jruby-1.7.10 - IO.read().size changes after the first access

Hi,

I am using jruby-1.7.10. I am having an issue that I don’t understand.
The
simple following test does not pass on jruby but works well on MRI. Any
idea ?

describe “IO.read” do
it “return the same value twice” do
obj = IO.read(File.join(File.dirname(FILE), “fixtures”,
‘img.jpg’))
obj.size.should eq obj.size
end
end

The first time obj.size returns 314. But after that it returns 311.

Thanks

Aymeric BRISSE

FYI, the bug is not reproducible when using the BINARY mode.

So in conclusion :

obj = IO.read(File.join(File.dirname(FILE), “fixtures”, ‘img.jpg’),
encoding: ‘UTF-8’)
obj.size # returns 314
obj.size # returns 311

obj = IO.read(File.join(File.dirname(FILE), “fixtures”, ‘img.jpg’),
encoding: ‘BINARY’)
obj.size # returns 314
obj.size # returns 311

Aymeric BRISSE

R&D Manager

Phone : (+33) 6 76 05 66 69

http://perfect-memory.com

http://www.ibc.org/page.cfm/Action=Exhib/ExhibID=1364/loadSearch=849339_2982
IBC Innovation Finalist Award 2013SEMTECH San Francisco Top 10 Semantic
Startup 2013 *

On Tue, Jan 28, 2014 at 12:13 PM, Aymeric Brisse <