Skip to content

Commit a355cd7

Browse files
committed
Don't double-interrupt the test HTTP server
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.
1 parent 7dfd5a1 commit a355cd7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

test/mri/open-uri/utils.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@ def start
2121
loop do
2222
client = @server.accept
2323
handle_request(client)
24-
client.close
24+
ensure
25+
client&.close
2526
end
27+
ensure
28+
@server.close
2629
end
2730
end
2831

2932
def shutdown
30-
@thread.kill
31-
@server.close
33+
@thread&.kill
34+
@thread&.join
3235
end
3336

3437
private
@@ -176,12 +179,14 @@ def start
176179
handle_request(client, method, path, request_line, headers)
177180
rescue IOError
178181
end
182+
ensure
183+
@server&.close
179184
end
180185
end
181186

182187
def shutdown
183-
@thread.kill
184-
@server.close
188+
@thread&.kill
189+
@thread&.join
185190
end
186191

187192
private

0 commit comments

Comments
 (0)