mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
7f29df4d79
Prior to this commit, an attempt to restart the StompBrokerRelayMessageHandler (SBRMH) resulted in an IllegalStateException stating that the ReactorNettyTcpClient was still in the process of "Shutting down." The reason is that a ReactorNettyTcpClient cannot be restarted after it has been closed, and that is by design. To address that issue, this commit introduces an `internallyManagedTcpClient` flag in SBRMH that is used to track whether SBRMH is in charge of managing the TcpClient internally or if the TcpClient was supplied by the user and is therefore managed externally. If SBRMH manages the TcpClient internally, isPauseable() returns `true`, and the `tcpClient` field is set to null (in stopInternal()) when the handler is stopped. Consequently, a new internally managed TcpClient will be created when the handler is restarted. If the TcpClient is managed externally, the handler is not considered to be "pauseable", and a reference to the externally managed TcpClient is retained after the handler has been stopped. If the ApplicationContext is subsequently restarted, the externally managed TcpClient will be reused -- which may or may not work, depending on the implementation of the TcpClient. Note, however, that this has always been the behavior of SBRMH with regard to stop/start scenarios for externally managed TcpClients. Closes gh-36266