NioEndpoint 在 Spring Boot 集成测试中从未超时

Lui*_*ñiz 5 grails spring-boot tomcat9

我试图通过在我的控制器中放置一个睡眠循环来在集成测试中引发服务器超时。我确实很感激那些想要提供帮助的人,但请不要问我为什么这样做,或者提出更好的方法来实现你认为我想要实现的目标:我只是想看到超时发生,或者理解为什么会这样没有发生。

为此,我将连接超时设置为一个较小的值。

server:
  tomcat:
    connection-timeout: 1000
Run Code Online (Sandbox Code Playgroud)

我可以看到套接字超时设置为那个小值,所以在SocketWrapper配置方面我认为我没问题。

然而,在 NioEndpoint 中,我可以看到 Poller 在此测试中未能评估 true:

} else if ((socketWrapper.interestOps() & SelectionKey.OP_READ) == SelectionKey.OP_READ ||
      (socketWrapper.interestOps() & SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE) {
Run Code Online (Sandbox Code Playgroud)

(这是图书馆tomcat-embed-core:9.0.4.1,951 路)

它无法评估为 true,因为除了第一次我的断点在那里被激活之外,每次socketWrapper.interestOps()都是0如此,而且第一次,超时不应该发生。

我可以做些什么不同的事情吗?