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.copy_stream doesn't accept objects that respond to #readpartial #5167

janko-m opened this Issue May 11, 2018 · 2 comments


None yet
2 participants

janko-m commented May 11, 2018


$ jruby -v
jruby (2.3.3) 2018-04-20 d8b1ff9 Java HotSpot(TM) 64-Bit Server VM 25.40-b25 on 1.8.0_40-b27 +jit [darwin-x86_64]
$ uname -a
Darwin Jankos-MacBook-Pro-2.local 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar  5 22:24:32 PST 2018; root:xnu-4570.51.1~1/RELEASE_X86_64 x86_64

Expected Behavior

IO.copy_stream on MRI accepts any object that responds to either #read or #readpartial as the source, so the following script works:

require "stringio"

class FakeIO
  def initialize(content)
    @io =

  def readpartial(*args)

IO.copy_stream("content"), File::NULL)

Actual Behavior

JRuby raises an exception when executing the above script:

ArgumentError: Should be String or IO
  copy_stream at org/jruby/
       <main> at script.rb:13

If I add a FakeIO#read method, the script executes without exceptions, and it calls FakeIO#read (MRI and Rubinius choose FakeIO#readpartial if both #read and #readpartial are available). It would be nice if JRuby supported #readpartial as well, it's needed for this PR.

@headius headius added this to the JRuby milestone May 13, 2018

@headius headius closed this in 30e9fa4 May 13, 2018


This comment has been minimized.


headius commented May 13, 2018

Thanks for the report!


This comment has been minimized.

janko-m commented May 13, 2018

Thanks for the fix! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment