Aias00 opened a new issue, #6448:
URL: https://github.com/apache/shenyu/issues/6448

   ### Current Behavior
   
   Every inbound TCP connection registers a new `ActivityConnectionObserver` on 
the shared EventBus, but there is no corresponding unregister path.
   
   Evidence:
   
   
`shenyu-protocol/shenyu-protocol-tcp/src/main/java/org/apache/shenyu/protocol/tcp/TcpBootstrapServer.java:84-90`
   
   ```java
   ActivityConnectionObserver connectionObserver = new 
ActivityConnectionObserver("TcpClient");
   eventBus.register(connectionObserver);
   Mono<Connection> client = 
connectionContext.getTcpClientConnection(getIp(socketAddress), 
connectionObserver);
   client.subscribe(clientConn -> bridge.bridge(serverConn, clientConn));
   ```
   
   `shutdown()` only disposes the server and loop resources:
   
   
`shenyu-protocol/shenyu-protocol-tcp/src/main/java/org/apache/shenyu/protocol/tcp/TcpBootstrapServer.java:115-119`
   
   ```java
   public void shutdown() {
       server.disposeNow();
       loopResources.dispose();
   }
   ```
   
   As connections come and go, EventBus retains each per-connection observer. 
This can grow without bound and makes each upstream removal event fan out to 
stale observers that no longer represent live connections.
   
   ### Expected Behavior
   
   Per-connection observers should be unregistered when the corresponding 
server/client connection terminates, or the TCP proxy should use a 
lifecycle-owned observer that does not grow per connection.
   
   ### Steps To Reproduce
   
   1. Enable TCP proxy.
   2. Repeatedly open and close TCP client connections.
   3. Each connection registers a new `ActivityConnectionObserver`; no code 
unregisters it when the connection closes.
   4. Later `removeCommonUpstream(...)` events are posted to all retained 
observers.
   
   ### Suggested Fix
   
   Attach cleanup to the connection lifecycle, for example via 
`onDispose`/`dispose` callbacks, and call 
`eventBus.unregister(connectionObserver)`. Alternatively, refactor to one 
observer managed by `TcpBootstrapServer` instead of one EventBus subscriber per 
connection.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to