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

IO#rewind ... doesn't. (when backed by a ByteArrayInputStream). #2381

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

IO#rewind ... doesn't. (when backed by a ByteArrayInputStream). #2381

headius opened this issue Dec 29, 2014 · 3 comments

Comments

@headius
Copy link
Member

headius commented Dec 29, 2014

From: http://jira.codehaus.org/browse/JRUBY-5891. Works in 1.7.18 and not on master.

See: https://gist.github.com/1043829 which includes a test case.

If you have a ByteArrayInputStream, then call #to_io on it, then you read from the stream and #rewind it, the offset into the stream doesn't change. I believe this is due to lseek dropping out the bottom of a conditional when it should perhaps throw an exception.

I am happy to provide a JUnit test and patch if folks agree with me that this is the wrong behavior. I just spent the better part of a day fixing broken behavior whose genesis was this issue.

@headius headius added this to the JRuby 9.0.0.0 milestone Dec 29, 2014
@enebo enebo modified the milestone: JRuby 9.0.0.0 Jul 14, 2015
@kares kares self-assigned this Sep 17, 2015
@kares kares added this to the JRuby 9.0.2.0 milestone Sep 17, 2015
@kares
Copy link
Member

kares commented Sep 17, 2015

seems to be working "correctly" on 9.0.1.0 :

data size before rewind: 100
Errno::EPIPE: Broken pipe - No message available
  rewind at org/jruby/RubyIO.java:1739
   <top> at bais_rewind.rb:10

... although I think with a little trick (by-passing newChannel) it would be possible to get ByteArrayInputStream seek-able - which I do found useful (will fire up a PR)

@enebo
Copy link
Member

enebo commented Nov 12, 2015

@kares is this finished?

@kares
Copy link
Member

kares commented Nov 13, 2015

yep - closing

@kares kares closed this as completed Nov 13, 2015
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

3 participants