Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Fix unseekable stream implementation of IO.copy_stream in #683

merged 1 commit into from

2 participants


Fixes JRUBY-7157
Fixed the transfer method to properly handle the fact that Java's FileChannel transferFrom method doesn't update the position of the destination channel. This version of the transfer method is only called if the source stream is unseekable (i.e. a socket or, in my case ServletUpload's FileItemStream). The bug occurs if the size of the source is greater than 4196 bytes.


Looks good, thanks!

@headius headius merged commit 2379957 into jruby:master

1 check failed

Details default The Travis build failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 30, 2013
  1. @pfoorion
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 1 deletion.
  1. +2 −1  src/org/jruby/
3  src/org/jruby/
@@ -4296,7 +4296,8 @@ public static IRubyObject copy_stream(ThreadContext context, IRubyObject recv,
private static long transfer(ReadableByteChannel from, FileChannel to) throws IOException {
long transferred = 0;
long bytes;
- while ((bytes = to.transferFrom(from, to.position(), 4196)) > 0) {
+ long startPosition = to.position();
+ while ((bytes = to.transferFrom(from, startPosition+transferred, 4196)) > 0) {
transferred += bytes;
Something went wrong with that request. Please try again.