File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -616,7 +616,9 @@ def unknown!(options = {})
616616 return
617617 end
618618
619- if options [ :generation ] && options [ :generation ] < pool &.generation
619+ # NOTE: You cannot use safe navigation here because if pool is nil you end
620+ # up trying to evaluate Integer < nil which is invalid.
621+ if options [ :generation ] && pool && options [ :generation ] < pool . generation
620622 return
621623 end
622624
Original file line number Diff line number Diff line change @@ -260,6 +260,19 @@ class ConnectionSpecTestException < Exception; end
260260 it_behaves_like 'marks server unknown'
261261 it_behaves_like 'logs a warning'
262262 it_behaves_like 'adds server diagnostics'
263+
264+ context 'when the error includes a generation' do
265+ let ( :exception ) do
266+ Mongo ::Error ::SocketError . new . tap do |exc |
267+ allow ( exc ) . to receive ( :generation ) . and_return ( 1234 )
268+ allow ( exc ) . to receive ( :service_id ) . and_return ( 'fake' )
269+ end
270+ end
271+
272+ it 'does not fail marking the server unknown' do
273+ expect ( error ) . to eq ( exception )
274+ end
275+ end
263276 end
264277
265278 context 'when #authenticate! raises an exception' do
You can’t perform that action at this time.
0 commit comments