JRuby

IOError exception in Net::FTP using 1.0.0RC3 under WinXP

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.0.0RC3
  • Fix Version/s: JRuby 1.0.1, JRuby 1.1b1
  • Component/s: Core Classes/Modules
  • Labels:
    None
  • Environment:
    WinXP, ftp to either a RS6000 host or a mainframe host supporting FTP, This is in a corporate environment, but inside our firewall.
  • Testcase included:
    yes
  • Number of attachments :
    2

Description

When doing Net::FTP.list command, I get an IOError exception after the last line of the list has been processed. Occurs under jirb or jruby

frag.rb:

require 'net/ftp'
ftp = Net::FTP.open('ftpmvs','uid','pw')
ftp.debug_mode = true
ftp.list() {|line| p line}
ftp.close

jirb transcript:

d:\Documents and Settings\mi01txp\My Documents>%JRUBY_HOME%\bin\jirb
irb(main):001:0> require 'frag'
put: TYPE A
get: 200 Representation type is Ascii NonPrint
put: PORT 10,67,54,109,7,51
get: 200 Port request OK.
put: LIST
get: 125 List started OK
"Volume Unit Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname"
"USER20 3390 2007/05/30 1 4 FB 80 3120 PO ISPF.ISPPROF"
"Migrated LIB.JCL"
"Migrated LIB.PRINT"
"Migrated LIB.SCRIPT"
"Migrated SECURE.FTP"
"USER29 3390 2007/05/31 1 1 VA 125 129 PS SPFLOG1.LIST"
IOError: No message available
from D:/jruby/lib/ruby/1.8/net/ftp.rb:625:in `loop'
from D:/jruby/lib/ruby/1.8/net/ftp.rb:431:in `retrlines'
from D:/jruby/lib/ruby/1.8/net/ftp.rb:625:in `mon_synchronize'
from D:/jruby/lib/ruby/1.8/net/ftp.rb:434:in `retrlines'
from D:/jruby/lib/ruby/1.8/net/ftp.rb:625:in `list'
from ./frag.rb:4
from (irb):1:in `require'
from (irb):1:in `binding'
from D:/jruby/lib/ruby/1.8/irb.rb:150:in `eval_input'
from D:/jruby/lib/ruby/1.8/irb.rb:70:in `signal_status'
from D:/jruby/lib/ruby/1.8/irb.rb:189:in `eval_input'
from D:/jruby/lib/ruby/1.8/irb.rb:70:in `each_top_level_statement'
from D:/jruby/lib/ruby/1.8/irb.rb:190:in `loop'
from D:/jruby/lib/ruby/1.8/irb.rb:190:in `catch'
from D:/jruby/lib/ruby/1.8/irb.rb:190:in `eval_input'
from D:/jruby/lib/ruby/1.8/irb.rb:70:in `start'
from :-1:in `catch'
from D:/jruby/lib/ruby/1.8/irb.rb:71:in `start'
from :-1irb(main):002:0>

output from running under jruby witn -d flag:

d:\Documents and Settings\mi01txp\My Documents>%JRUBY_HOME%\bin\jruby -d frag.rb

put: TYPE A
get: 200 Representation type is Ascii NonPrint
put: PORT 10,67,54,109,5,6
get: 200 Port request OK.
put: LIST
get: 125 List started OK
"Volume Unit Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname"
"USER20 3390 2007/05/30 1 4 FB 80 3120 PO ISPF.ISPPROF"
"Migrated LIB.JCL"
"Migrated LIB.PRINT"
"Migrated LIB.SCRIPT"
"Migrated SECURE.FTP"
"USER29 3390 2007/05/31 1 1 VA 125 129 PS SPFLOG1.LIST"
D:/jruby/lib/ruby/1.8/net/ftp.rb:625:in `loop': No message available (IOError)
from D:/jruby/lib/ruby/1.8/net/ftp.rb:431:in `retrlines'
from D:/jruby/lib/ruby/1.8/net/ftp.rb:625:in `mon_synchronize'
from D:/jruby/lib/ruby/1.8/net/ftp.rb:434:in `retrlines'
from D:/jruby/lib/ruby/1.8/net/ftp.rb:625:in `list'
from frag.rb:4

Outpur from running under ruby:

d:\Documents and Settings\mi01txp\My Documents>ruby frag.rb
put: TYPE A
get: 200 Representation type is Ascii NonPrint
put: PORT 10,67,54,109,5,10
get: 200 Port request OK.
put: LIST
get: 125 List started OK
"Volume Unit Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname"
"USER20 3390 2007/05/30 1 4 FB 80 3120 PO ISPF.ISPPROF"
"Migrated LIB.JCL"
"Migrated LIB.PRINT"
"Migrated LIB.SCRIPT"
"Migrated SECURE.FTP"
"USER29 3390 2007/05/31 1 1 VA 125 129 PS SPFLOG1.LIST"
get: 250 List completed successfully.

d:\Documents and Settings\mi01txp\My Documents>

  1. frag_sample.rb
    05/Jun/07 9:29 AM
    0.1 kB
    Thomas Porter
  2. rubyiofix.diff
    22/Jul/07 11:18 PM
    2 kB
    Nicolas Modrzyk

Issue Links

Activity

Hide
Thomas Porter added a comment -

I set up vsftpd on my linux laptop and was able to duplicate this error when FTP'ing to localhsot as an anonymous user, so it is not related to the corporate firewall/proxy environment or the fact that i was FTp'ing to unusual hosts (like an IBM mainframe)

Tom Porter

Show
Thomas Porter added a comment - I set up vsftpd on my linux laptop and was able to duplicate this error when FTP'ing to localhsot as an anonymous user, so it is not related to the corporate firewall/proxy environment or the fact that i was FTp'ing to unusual hosts (like an IBM mainframe) Tom Porter
Hide
Charles Oliver Nutter added a comment -

Moving to 1.x

Show
Charles Oliver Nutter added a comment - Moving to 1.x
Hide
Max Thoursie added a comment -

I have the same problem. I am unable to use net/ftp.rb at all with jruby, which is very sad since I have a few scripts that I whold like to run with jruby, but requires net/ftp

My repro:

require 'net/ftp'

Net::FTP.open('ftp.sunet.se') do |ftp|
ftp.login
puts ftp.list
end

which outputs:

/usr/local/jruby-1.0.0RC3/lib/ruby/1.8/net/ftp.rb:630:in `loop': No message available (IOError)
from /usr/local/jruby-1.0.0RC3/lib/ruby/1.8/net/ftp.rb:431:in `retrlines'
from /usr/local/jruby-1.0.0RC3/lib/ruby/1.8/net/ftp.rb:630:in `mon_synchronize'
from /usr/local/jruby-1.0.0RC3/lib/ruby/1.8/net/ftp.rb:434:in `retrlines'
from /usr/local/jruby-1.0.0RC3/lib/ruby/1.8/net/ftp.rb:630:in `list'
from test.rb:5
from :-1:in `open'
from test.rb:6

I would prefer to see this fixed in 1.0, since it's part of core ruby funcionality

Show
Max Thoursie added a comment - I have the same problem. I am unable to use net/ftp.rb at all with jruby, which is very sad since I have a few scripts that I whold like to run with jruby, but requires net/ftp My repro: require 'net/ftp' Net::FTP.open('ftp.sunet.se') do |ftp| ftp.login puts ftp.list end which outputs: /usr/local/jruby-1.0.0RC3/lib/ruby/1.8/net/ftp.rb:630:in `loop': No message available (IOError) from /usr/local/jruby-1.0.0RC3/lib/ruby/1.8/net/ftp.rb:431:in `retrlines' from /usr/local/jruby-1.0.0RC3/lib/ruby/1.8/net/ftp.rb:630:in `mon_synchronize' from /usr/local/jruby-1.0.0RC3/lib/ruby/1.8/net/ftp.rb:434:in `retrlines' from /usr/local/jruby-1.0.0RC3/lib/ruby/1.8/net/ftp.rb:630:in `list' from test.rb:5 from :-1:in `open' from test.rb:6 I would prefer to see this fixed in 1.0, since it's part of core ruby funcionality
Hide
Le Huy added a comment -

I encountered same problem and come up with the following simple workaround

if PLATFORM=='java'
#fix error jruby socket implementation
TCPSocket.class_eval
alias original_gets gets
def gets(sep_string=$/)
original_gets sep_string
rescue IOError
nil
end
end
end

Show
Le Huy added a comment - I encountered same problem and come up with the following simple workaround if PLATFORM=='java' #fix error jruby socket implementation TCPSocket.class_eval alias original_gets gets def gets(sep_string=$/) original_gets sep_string rescue IOError nil end end end
Hide
Nicolas Modrzyk added a comment -

This fixes the problem for the EOF at the end of reading. Here was the original exception:
java.io.EOFException
at org.jruby.util.IOHandlerNio.gets(IOHandlerNio.java:324)
at org.jruby.RubyIO.internalGets(RubyIO.java:516)
at org.jruby.RubyIO.gets(RubyIO.java:954)

There is a method in NIOHandler called isEOF() but it looks really time consuming to check for the end of file each time we want to read.

This patch also includes a stub for the close_write method which is supported by ruby but not by jruby.

Show
Nicolas Modrzyk added a comment - This fixes the problem for the EOF at the end of reading. Here was the original exception: java.io.EOFException at org.jruby.util.IOHandlerNio.gets(IOHandlerNio.java:324) at org.jruby.RubyIO.internalGets(RubyIO.java:516) at org.jruby.RubyIO.gets(RubyIO.java:954) There is a method in NIOHandler called isEOF() but it looks really time consuming to check for the end of file each time we want to read. This patch also includes a stub for the close_write method which is supported by ruby but not by jruby.
Hide
Nicolas Modrzyk added a comment -

Not sure it was clear enough in my previous comment.

The second attachment:
http://jira.codehaus.org/secure/attachment/28558/rubyiofix.diff

is the fix for this.

Show
Nicolas Modrzyk added a comment - Not sure it was clear enough in my previous comment. The second attachment: http://jira.codehaus.org/secure/attachment/28558/rubyiofix.diff is the fix for this.
Hide
Thomas E Enebo added a comment -

Applied on 1.0 branch

Show
Thomas E Enebo added a comment - Applied on 1.0 branch

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: