JRuby and open-uri File handle issue

As stated in another thread we have been seeing the number of open file
handles increase through out the day until Tomcat is restarted.

We are using Rails 2.3.5 with Tomcat 5 OpenJDK 1.6.0-b09 and Jruby 1.4
on RHEL 5.4.

I have finally tracked down the culprit. Using open-uri like so:

open(“http://www.google.com”) {|f|
f.each_line {|line| p line}
}

Causes following to be added to the tomcat lsof entries:

java 20153 tomcat 95r FIFO 0,6 12572360
pipe
java 20153 tomcat 99w FIFO 0,6 12572360
pipe
java 20153 tomcat 100r 0000 0,11 0 12572361
eventpoll

These are not released until Tomcat is restarted. Note that there are
always two “pipes” and 1 eventpoll entry added each time the open
function is executed.

Any ideas on this one? Is this a known issue?

NOTE: its not specific to the open-uri wrapper. The problem is down in
the net/http class somewhere.

I can duplicate with the following as well:

Net::HTTP.get_print URI.parse(‘http://www.example.com/index.html’)

I have setup a test outside of rails an Tomcat:

require ‘open-uri’

x = open(“http://www.lecza.com”)
puts x.read
x.close
x = nil
puts STDIN.read

When I run the code above with Ruby those handles are not stuck (while
on the read)

When I run it with Jruby I see the handles stuck until I terminate the
script.

I tried Jruby 1.4.0 and 1.5.0 RC2 and both have the same issue.

FYI - I opened a bug: http://jira.codehaus.org/browse/JRUBY-4767

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs