Too many open files after upgrade to Spring Boot 2.2.8

最近新项目采用最新的 Spring Boot 2.2.8.RELEASE 版本,但是发布到部署环境后,提示 Too many open files 的错误。

错误日志

2020-07-03 11:09:54.469 [http-nio-9000-Acceptor] ERROR org.apache.tomcat.util.net.Acceptor - Socket accept failed
java.io.IOException: Too many open files
	at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
	at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:419)
	at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:247)
	at org.apache.tomcat.util.net.NioEndpoint.serverSocketAccept(NioEndpoint.java:469)
	at org.apache.tomcat.util.net.NioEndpoint.serverSocketAccept(NioEndpoint.java:71)
	at org.apache.tomcat.util.net.Acceptor.run(Acceptor.java:95)
	at java.lang.Thread.run(Thread.java:748)

经过查看stackoverflow、github上的相关问题,发现主要是Spring Boot 2.2.8.RELEASE依赖的reactor-netty版本号为0.9.8.RELEASE,这个版本会导致上述BUG。

查询的相关资料

https://stackoverflow.com/questions/62655110/spring-boot-admin-too-many-open-files-in-system-error
https://github.com/spring-projects/spring-boot/issues/21934
https://github.com/spring-projects/spring-boot/issues/21923

按照官方的解决方式,采用在pom.xml升级新版本的方式

以下提供解决方案

<!-- bug fix Too many open files https://github.com/reactor/reactor-netty/issues/1152 -->
<dependency>
    <groupId>io.projectreactor.netty</groupId>
    <artifactId>reactor-netty</artifactId>
    <version>0.9.9.RELEASE</version>
</dependency>
原文地址:https://www.cnblogs.com/fengzhentian/p/13277764.html