Issue Details (XML | Word | Printable)

Key: JRUBY-1108
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Thomas Porter
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
JRuby

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

Created: 05/Jun/07 09:29 AM   Updated: 22/Dec/07 06:28 AM   Resolved: 26/Jul/07 12:18 AM
Return to search
Component/s: Core Classes/Modules
Affects Version/s: JRuby 1.0.0RC3
Fix Version/s: JRuby 1.0.1, JRuby 1.1b1

Time Tracking:
Not Specified

File Attachments: 1. File frag_sample.rb (0.1 kB)
2. File rubyiofix.diff (2 kB)

Environment: WinXP, ftp to either a RS6000 host or a mainframe host supporting FTP, This is in a corporate environment, but inside our firewall.
Issue Links:
Related
 

Testcase included: yes


 Description  « Hide

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>



Thomas Porter added a comment - 05/Jun/07 10:51 AM

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


Charles Oliver Nutter added a comment - 06/Jun/07 04:28 AM

Moving to 1.x


Max Thoursie added a comment - 07/Jun/07 02:43 AM

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


Le Huy added a comment - 22/Jul/07 04:19 AM

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


Nicolas Modrzyk added a comment - 22/Jul/07 11:18 PM

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.


Nicolas Modrzyk added a comment - 22/Jul/07 11:20 PM

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.


Thomas E Enebo added a comment - 23/Aug/07 10:34 AM

Applied on 1.0 branch