Using String.from_java_bytes and send_data to write binary data is broken
-------------------------------------------------------------------------
Key: JRUBY-1019
URL: http://jira.codehaus.org/browse/JRUBY-1019
Project: JRuby
Issue Type: Bug
Components: Java Integration
Reporter: Cliff Moon
I'm using String.from_java_bytes to convert a rendered graph to a ruby string
and then sending it to the browser using the send_data method in rails. This
worked for a while, but it was broken the last time I updated from SVN.
Rolling back to version 3641, where String.from_java_bytes was introduced,
seems to fix the problem.
I think the problem is related to either casting or masking problems occurring
when rails is trying to send the stream to the browser. In trying to track
this problem down, I also used String#each_byte to compare the java byte array
with the ruby string. This failed. The java byte array gave -119, whereas the
ruby string gave 137, indicating that inside of the ruby string the bytes were
being up-converted then bit masked back as bytes since 137 is the two's
complement of 119.
The interesting thing is that I patched RubyString.java to not bitmask in
each_byte, aref, and a couple of other methods. My test comparing the java
array with the ruby string byte by byte passed, but the graph was still getting
corrupted. There must be something else happening in the IO libraries where
bytes are being mangled.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email