@@ -234,10 +234,12 @@ class DefaultServerSpecification extends Specification {
234234 ]
235235 }
236236
237- def ' failed open should invalidate the server ' () {
237+ def ' network error should not invalidate the pool ' () {
238238 given :
239239 def connectionPool = Mock (ConnectionPool )
240- connectionPool. get(_) >> { throw exceptionToThrow }
240+ connectionPool. get(_) >> {
241+ throw exceptionToThrow
242+ }
241243 def serverMonitor = Mock (ServerMonitor )
242244 def server = defaultServer(connectionPool, serverMonitor)
243245
@@ -247,8 +249,8 @@ class DefaultServerSpecification extends Specification {
247249 then :
248250 def e = thrown(MongoException )
249251 e. is(exceptionToThrow)
250- 1 * connectionPool. invalidate(exceptionToThrow )
251- 1 * serverMonitor. cancelCurrentCheck()
252+ 0 * connectionPool. invalidate(_ )
253+ 0 * serverMonitor. cancelCurrentCheck()
252254
253255 where :
254256 exceptionToThrow << [
@@ -281,7 +283,7 @@ class DefaultServerSpecification extends Specification {
281283 ]
282284 }
283285
284- def ' failed open should invalidate the server asynchronously' () {
286+ def ' failed open should not invalidate the pool asynchronously' () {
285287 given :
286288 def connectionPool = Mock (ConnectionPool )
287289 connectionPool. getAsync(_, _) >> { it. last(). onResult(null , exceptionToThrow) }
@@ -301,8 +303,8 @@ class DefaultServerSpecification extends Specification {
301303 then :
302304 ! receivedConnection
303305 receivedThrowable. is(exceptionToThrow)
304- 1 * connectionPool. invalidate(exceptionToThrow)
305- 1 * serverMonitor. cancelCurrentCheck()
306+ 0 * connectionPool. invalidate(exceptionToThrow)
307+ 0 * serverMonitor. cancelCurrentCheck()
306308
307309
308310 where :
0 commit comments