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
support (seekable) ByteArrayInputStream#to_io.rewind #3337
Conversation
@kares I appreciate the attribution but the code at 6142ea3#diff-b60adbaec9c15033c4eb0231a09d211aR46 worries me. We can't incorporate code from GPL codebases like this, even if they're been massaged into place a little. I'd suggest you look at the Android implementation of this logic, which is licensed Apache-2.0. We can incorporate them into a separate file with an Apache license header and it should be compatible with all three of our licenses. Here's the Android 4.3 impl of Channels at equivalent read method: https://android.googlesource.com/platform/libcore/+/android-4.3_r1/luni/src/main/java/java/nio/channels/Channels.java#297 |
@headius thanks, the problematic part is now re-implemented as suggested. |
@kares I'll pull it down today, review and make sure it's building, and push it out. |
Testing seems fine, I'll push shortly. Last suggestions, if you get a chance (just throw them on master):
|
…gested in jruby#3337) ... also keep the fields needed to avoid constant lookup in ByteArrayInputStream.class
except
FileInputStream
it seems quite useful to be able to rewind/seek abyte[]
backed streamthis is not possible using
Channels.newChannel
as the returned channel (except for files) is not seekablebut using the 9K refactored RubyIO its fairly easy to play a trick by returning a custom channel instance ...
1.7.x remains behaving weirdly on
rewind
... more notes at #2381