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.
The text was updated successfully, but these errors were encountered:
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)
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.
The text was updated successfully, but these errors were encountered: