File tree Expand file tree Collapse file tree
driver-core/src/test/unit/com/mongodb/internal/connection Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -259,6 +259,28 @@ class DefaultServerSpecification extends Specification {
259259 ]
260260 }
261261
262+ def ' DNS lookup failure should invalidate the pool' () {
263+ given :
264+ def exceptionToThrow = new MongoSocketException (' DNS lookup failed' , new ServerAddress (),
265+ new UnknownHostException (' no such host' ))
266+ BackpressureErrorLabeler . applyLabelsIfEligible(exceptionToThrow)
267+ assert ! exceptionToThrow. hasErrorLabel(MongoException . SYSTEM_OVERLOADED_ERROR_LABEL )
268+
269+ def connectionPool = Mock (ConnectionPool )
270+ connectionPool. get(_) >> { throw exceptionToThrow }
271+ def serverMonitor = Mock (ServerMonitor )
272+ def server = defaultServer(connectionPool, serverMonitor)
273+
274+ when :
275+ server. getConnection(OPERATION_CONTEXT )
276+
277+ then :
278+ def e = thrown(MongoException )
279+ e. is(exceptionToThrow)
280+ 1 * connectionPool. invalidate(exceptionToThrow)
281+ 1 * serverMonitor. cancelCurrentCheck()
282+ }
283+
262284 def ' failed authentication should invalidate the connection pool' () {
263285 given :
264286 def connectionPool = Mock (ConnectionPool )
You can’t perform that action at this time.
0 commit comments