Skip to content

Commit

Permalink
Don't double-interrupt the test HTTP server
Browse files Browse the repository at this point in the history
This is the same situation as ruby/net-http#197, where a server
thread is interrupted twice and ends up in a loop. This is more
fallout from removing WEBrick and replacing its use in tests with
small hand-written server code that apparently exposes a behavior
difference in JRuby.
  • Loading branch information
headius committed Dec 27, 2024
1 parent 7dfd5a1 commit a355cd7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/mri/open-uri/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ def start
loop do
client = @server.accept
handle_request(client)
client.close
ensure
client&.close
end
ensure
@server.close
end
end

def shutdown
@thread.kill
@server.close
@thread&.kill
@thread&.join
end

private
Expand Down Expand Up @@ -176,12 +179,14 @@ def start
handle_request(client, method, path, request_line, headers)
rescue IOError
end
ensure
@server&.close
end
end

def shutdown
@thread.kill
@server.close
@thread&.kill
@thread&.join
end

private
Expand Down

0 comments on commit a355cd7

Please sign in to comment.