Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.1RC3
-
Fix Version/s: JRuby 1.1
-
Component/s: Core Classes/Modules
-
Labels:None
-
Environment:All
-
Patch Submitted:Yes
-
Number of attachments :
Description
I was having a problem where larger http POST operations was resulting in truncation of data coming into the Ruby ActionController. I debugged this under Eclipse and discovered the following:
In class ChannelStream there is a method:
private ByteList bufferedRead(int number)
This method reads from an input channel and transfers the data into a ByteList. Since the data can be returned by the channel reader in chunks, there is a loop to read it chunk by chunk, appending it into the ByteList called result. However, the loop control has an apparent fault in it, which results in only the first chunk being read.
The relevant line is:
while (read == BUFSIZE && result.length() != number) { // not complete. try to read more
I haven't analysed this too deeply, other than to observe that in my case, the first call to read from the channel does not return all the bytes available, even though there is room in the buffer. (I don't think the java API guarantees that it will). By fiddling in the debugger, I confirmed that if it went around the loop a second time the remaining bytes were indeed collected.
So, I modified the loop control to remove the first test, since that seemed superfluous to me on superficial examination...
while (result.length() != number)
This appears to have fixed my problem, but could you please confirm that my fix is correct, and that there aren't any other similar bugs in this module?
I experienced similar problem. Milton's fix resolved it. See:
http://archive.jruby.codehaus.org/user/47E5A81A.60100%40csinitiative.com
for details
(the archive seems way behind btw)