You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When multiple threads are accessing a connection collection, the
underlying `@collections` object can change at any point (after
`connections.empty?`, `dead`, or `dead_connection.alive!`). This means
the selector is not necessarily operating on a collection with an alive
connection. Since selectors currently only look at alive connections,
`selector.select` can return `nil` when a dead connection would be
better.
If you run the new test on jruby without the fix, you should see it
returning `nil` and raising a `NoMethodError`:
```
NoMethodError: undefined method `dead!' for nil:NilClass
<main> at /Users/dharsha/repos/elastic/elasticsearch-ruby/elasticsearch-transport/spec/elasticsearch/connections/collection_spec.rb:257
each at org/jruby/RubyEnumerator.java:396
map at org/jruby/RubyEnumerable.java:886
<main> at /Users/dharsha/repos/elastic/elasticsearch-ruby/elasticsearch-transport/spec/elasticsearch/connections/collection_spec.rb:256
```
This switches to trying the selector first and falling back to the
connection with the least errors if no alive connection is found. The
fallback operates on `@connections` directly because the connections may
have changed state after `selector.select` was called.
Looks like this was introduced here: b5019c2
0 commit comments