-
-
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.copy_stream replaces read chunk even if it's duplicated #5048
Comments
I'm not at a terminal now, hit can you try this with a snapshot of 9.1.16? I did a bunch of work this cycle to improve copy_stream. |
I successfully build JRuby from
I tried running |
Try downloading a nightly from the link http://jruby.org/download |
@headius Strange, I get the same error when using the executable from the nightly link. |
Yeah really seems like an env issue. Try a clean shell, make sure no vars are redirecting commands somewhere they should not be. I'll have a look tomorrow too. |
@headius You're right, running from a clean shell worked 👍 And yes, the script now produces correct output on the 9.1.16.0 snapshot, which is great. Thank you very much! ❤️ |
It seems likely this was the same issue as #4093. I wish you had filed first...that one was complicated to diagnose! 😆 |
Environment
Expected Behavior
I'm using a trick in HTTP.rb where I utilize
IO.copy_stream
to yield chunks of data into a block. However, the tests for this behaviour are failing on JRuby.I managed to isolate the problem in this script:
On MRI this prints
16*1024
charactersa
and10*1024
charactersb
.Actual Behavior
On JRuby this script prints
3 x 8*1024
charactersb
and1 x 2*1024
charactersb
. This totals to the correct number of characters, but they're allb
. Since JRuby seems to use chunk size of 8KB (unlike MRI which uses 16KB), I expected the output to be2 x 8*1024
charactersa
,1 x 8*1024
charactersb
and1 x 2*1024
charactersb
.I tried printing each chunk as it's yielded:
And the chunks were in fact correct. So it seems that, even though I duplicated the string, JRuby still somehow overrode it when reading subsequent chunks. And in a strange way too, I would have expected to get 4x the last chunk (
2*1024
charactersb
), but instead JRuby kept the string length and still somehow replaced the content.The text was updated successfully, but these errors were encountered: