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 = {})
616
616
return
617
617
end
618
618
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
620
622
return
621
623
end
622
624
Original file line number Diff line number Diff line change @@ -260,6 +260,19 @@ class ConnectionSpecTestException < Exception; end
260
260
it_behaves_like 'marks server unknown'
261
261
it_behaves_like 'logs a warning'
262
262
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
263
276
end
264
277
265
278
context 'when #authenticate! raises an exception' do
You can’t perform that action at this time.
0 commit comments