We were getting truncated POST packets and garbled params in some of our larger post requests. It looks like (though I don't know why) the population of the in-memory ByteBuffer from the Jetty input stream was not copying all the data in one call.
The following patch forces multiple passes of the input stream until it is exhausted. This is not extensively tested, particularly in a multi-threaded environment, but it fixes the problem for us in a traditional (Rails 2.1.2) environment.
— a/src/main/java/org/jruby/rack/input/RackRewindableInput.java
+++ b/src/main/java/org/jruby/rack/input/RackRewindableInput.java
@@ -71,7 +71,7 @@ public class RackRewindableInput extends RackBaseInput {
private MemoryBufferRackInput(ReadableByteChannel input) throws
IOException {
memoryBuffer = ByteBuffer.allocate(getBufferSize());
- input.read(memoryBuffer);
+ while (input.read(memoryBuffer) > 0 &&
memoryBuffer.hasRemaining());
full = !memoryBuffer.hasRemaining();
memoryBuffer.flip();
}
In f5ee0d9.