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

   ### Current behavior
   
   `EventLoopNettyCustomizer.apply()` allocates a fresh 
`LoopResources.create("shenyu-netty", ...)` and supplies it to 
`HttpServer.runOn()`. No lifecycle owner retains/disposes this custom resource. 
Spring Boot's server stop closes the bound server but does not dispose the 
supplied custom event loops.
   
   ### Location
   
   
[ShenyuNettyWebServerConfiguration.java:154–157](https://github.com/apache/shenyu/blob/66d7d954ca37d651a5ad916f988a8081157a7ab4/shenyu-spring-boot-starter/shenyu-spring-boot-starter-gateway/src/main/java/org/apache/shenyu/springboot/starter/netty/ShenyuNettyWebServerConfiguration.java#L154).
   
   ### Reproduction / validation
   
   A probe compiled the current gateway configuration, created its actual 
NettyReactiveWebServerFactory with one worker/selector, bound an empty HTTP 
handler to an ephemeral loopback port, started the server, and called 
`server.stop()`:
   
   ```text
   BEFORE_STOP loopsDisposed=false threads=1
   AFTER_STOP loopsDisposed=false threads=1
   AFTER_EXPLICIT_DISPOSE loopsDisposed=true threads=0
   ```
   
   The probe captured the server's actual configured LoopResources and 
explicitly disposed it afterward so it left no thread/socket behind. An 
independent reviewer inspected Spring Boot 3.3.1 NettyWebServer.stop() and 
Reactor Netty 1.1.20 resource handling to confirm the ownership gap.
   
   ### Impact / scope
   
   Stopping/restarting embedded gateway servers can retain custom event-loop 
threads and resources from earlier lifecycles. These threads are daemon threads 
(`true` in the create call), so this issue does **not** claim they necessarily 
prevent JVM exit. The runtime reproduction checks embedded server start/stop, 
while missing context ownership is established by source inspection.
   
   ### Suggested fix
   
   Own the custom LoopResources through an application/server lifecycle 
component and dispose them when that lifecycle ends, or use the existing 
Spring-managed resource factory consistently. Account for bind failures and 
restarts, and avoid disposing loops shared by still-running servers.
   
   ### Related existing work
   
   #3284 concerns allocating HTTP **client** loops per request; #5047 and #6018 
concern TCP proxy listeners; #3063 discusses client runOn memory usage. This 
report concerns the gateway HTTP **server** customizer and a single server's 
start/stop lifecycle, reproduced independently of those modules. 
Historical/live loop-resource searches did not find the same shutdown defect.
   
   
   ### Reviewed revision
   
   Apache ShenYu 2.7.2-SNAPSHOT, 
`master@66d7d954ca37d651a5ad916f988a8081157a7ab4`. Severity Medium / P2; 
confidence high. Unit-test and CI issue categories excluded.
   


-- 
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