JRuby

Timeouts in Net::HTTP raise Timeout::ExitException instead of Timeout::Error for Ruby 1.8

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.3.1
  • Fix Version/s: JRuby 1.4
  • Component/s: Core Classes/Modules
  • Labels:
    None
  • Environment:
    Linux 2.6.26-2-686, debian lenny, java 1.6.0_12
  • Testcase included:
    yes
  • Number of attachments :
    1

Description

Timeouts raised by Net::HTTP raise Timeout::ExitException instead of Timeout::Error.

For example:

require 'net/http'
require 'timeout'

begin
http = Net::HTTP.new('www.google.de')
http.open_timeout = 0.01
response = http.start do |h|
h.request_get '/index.html'
end
rescue Exception => e
puts "Got #{e.class}: #{e}"
end

On MRI:

-> Got Timeout::Error: execution expired

On JRuby 1.3.1

-> Got Timeout::ExitException: execution expired

Activity

Hide
Charles Oliver Nutter added a comment -

Weird, I wonder how this snuck through various tests for timeout. Fixing...

Show
Charles Oliver Nutter added a comment - Weird, I wonder how this snuck through various tests for timeout. Fixing...
Hide
Charles Oliver Nutter added a comment -

I've found the problem...I'll get a patch in momentarily.

Show
Charles Oliver Nutter added a comment - I've found the problem...I'll get a patch in momentarily.
Hide
Charles Oliver Nutter added a comment -

Fixed with tests in 065a6b6. The problem was that there was a path through the timeout logic that allowed the "internal" exception used for unrolling the stack to propagate all the way out. By default, we'd been using ExitException for this, instead of an anonymous exception like timeout.rb. I fixed the code to use an anonymous exception (JRUBY-3820) and also moved the last exceptional path into the appropriate location, so that the anonymous exception can be rescued and the correct exception (Timeout::Error) be thrown instead.

Show
Charles Oliver Nutter added a comment - Fixed with tests in 065a6b6. The problem was that there was a path through the timeout logic that allowed the "internal" exception used for unrolling the stack to propagate all the way out. By default, we'd been using ExitException for this, instead of an anonymous exception like timeout.rb. I fixed the code to use an anonymous exception (JRUBY-3820) and also moved the last exceptional path into the appropriate location, so that the anonymous exception can be rescued and the correct exception (Timeout::Error) be thrown instead.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: