Fix copy_stream bug on JRuby