-
-
Notifications
You must be signed in to change notification settings - Fork 925
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.to_inputstrea.read(buf) shall read partially #3114
Comments
We might miss this for rc2 but I can confirm this has not been fixed since rc1. |
If I modify your script to just read from the IO objects popen3 returns, MRI also blocks until 10 seconds have elapsed.
Based on that, it seems like this is not necessarily something we're doing wrong. A read against the InputStream you acquire will attempt to read to 1024 bytes or EOF. Since the process is still running, there's no EOF, so it blocks waiting for more data. JRuby 1.7 blocks until process end with normal IO read, but returns quickly for the InputStream read, so there is a behavior change here. However the behavior change may be more correct. I'm open to input here. JRuby 9k's InputStream here is just doing a call to IO read. |
According to the Java API document, I think InputStream#read blocks until one byte read, but doesn't block until buffer filled. https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html#read-byte:A-
Ruby IO has readpartial. So you can read partially. But InputStream doesn't have such a method. So you can't read partially from InputStream. I want to process some part of my application in Java code for performance reason. |
test.c
test.rb
Compile to a.out.
jruby-1.7.20.1
jruby-9.0.0.0.rc1
InputStream#read(byte[] b) should read partially. But In jruby 9k, to_inputstrea.read blocks until a buffer completely filled.
The text was updated successfully, but these errors were encountered: