tomcat9illegalmonitorstateexcep

Tomcat throws java.lang.IllegalMonitorStateException: null when doing data writing, why?


SpringBoot's embeded tomcat throws a IllegalMonitorStateException when writing data back to some http request in our production environment. It happens more frequently at high load.

tomcat verion: tomcat-embed-core:9.0.31

Below is part of the stacktrace:

java.lang.IllegalMonitorStateException: null
        at java.lang.Object.wait(Native Method)
        at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.doWrite(NioEndpoint.java:1290)
        at org.apache.tomcat.util.net.SocketWrapperBase.doWrite(SocketWrapperBase.java:741)
        at org.apache.tomcat.util.net.SocketWrapperBase.flushBlocking(SocketWrapperBase.java:694)
        at org.apache.tomcat.util.net.SocketWrapperBase.flush(SocketWrapperBase.java:684)

THANKS.


Solution

  • You can try to upgrade the version to 9.0.32, as the part of the logic that you reported an error on, was reverted in 9.0.32.

    https://github.com/apache/tomcat/commit/6e60713c75141bc00f03f08f759df993a6416c71