Skip to content

Commit

Permalink
Fix a test that deadlocks in JRuby
Browse files Browse the repository at this point in the history
I think the problem is that the reactor most of the time is not in select when #stop is called, so it just skips to the stopping phase directly. With this test implementation the reactor will be blocked when #stop is called, and the test will kind of test that it continues running until the future resolves.

It's not a great test to say the least.
  • Loading branch information
iconara committed Apr 28, 2016
1 parent 27fa868 commit fe3fdd2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions spec/ione/io/io_reactor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,17 @@ def fake_connected(connection)
end

it 'keeps running until stop completes' do
running_barrier = Queue.new
stop_barrier = Queue.new
barrier = Queue.new
selector.handler do
running_barrier.push(nil)
stop_barrier.pop
barrier.pop
[[], [], []]
end
reactor.start.value
future = reactor.stop
running_barrier.pop
barrier.push(nil)
reactor.should be_running
stop_barrier.push(nil) until future.completed?
barrier.push(nil) until future.completed?
reactor.should_not be_running
end

it 'unblocks the reactor' do
Expand Down

0 comments on commit fe3fdd2

Please sign in to comment.