when I use spring-cloud-starter-alibaba-sentine:2.2.9.RELEASE with sentinel-transport-netty-http in my spring-boot application , the jvm can not exit when I call actuator/shutdown endpoint such as exec curl -X POST http://ip:port/actuator/shutdown.
This is because of com.alibaba.csp.sentinel.transport.command.netty.HttpServer thread has not closed when the application context closed.
Describe what you expected to happen
Process finished with exit code 0
How to reproduce it (as minimally and precisely as possible)
run you local sentinel dashboard on port 8080
clone a simple demo such as git clone git@github.com:tobrainto/sentinel-demo.git
exec curl -X GET http://localhost:8090/hello to trigger some init for sentinel
exec curl -X POST http://localhost:8090/actuator/shutdown to shutdown the application
you cannot find the info which mean the process finished as blow.
Disconnected from the target VM, address: '127.0.0.1:59120', transport: 'socket'
Process finished with exit code 0
and you can see some non-daemon thread still alive
![image](https://user-images.githubusercontent.com/71546831/202894150-c4b1fd91-2576-4f27-b016-c91d1d401d2e.png)
### Tell us your environment
Java11 、spring-cloud-starter-alibaba-sentine:2.2.9.RELEASEE 、spring-boot:2.6.6
### Try fixed
[I try to fixed it like this in spring-cloud-starter-alibaba-sentinel](https://github.com/alibaba/spring-cloud-alibaba/compare/2021.x...tobrainto:spring-cloud-alibaba:fix-sentinel-shutdown)
java.lang.InterruptedException
at java.base/java.lang.Object.wait(Native Method)
at java.base/java.lang.Object.wait(Object.java:328)
at io.netty.util.concurrent.DefaultPromise.await(DefaultPromise.java:253)
at io.netty.channel.DefaultChannelPromise.await(DefaultChannelPromise.java:131)
at io.netty.channel.DefaultChannelPromise.await(DefaultChannelPromise.java:30)
at io.netty.util.concurrent.DefaultPromise.sync(DefaultPromise.java:404)
at io.netty.channel.DefaultChannelPromise.sync(DefaultChannelPromise.java:119)
at io.netty.channel.DefaultChannelPromise.sync(DefaultChannelPromise.java:30)
at com.alibaba.csp.sentinel.transport.command.netty.HttpServer.start(HttpServer.java:86)
at com.alibaba.csp.sentinel.transport.command.NettyHttpCommandCenter$1.run(NettyHttpCommandCenter.java:50)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
so at the some I think `channel.closeFuture().sync();` may need a try catch to ingore the unnecessary exception trace print
![image](https://user-images.githubusercontent.com/71546831/202911890-11dfcd08-10e0-4dbc-bcef-e40375717e23.png)
### I also report it to spring-cloud-alibaba
[spring-cloud-alibaba/issues/2920
](https://github.com/alibaba/spring-cloud-alibaba/issues/2920
)
I first report it to spring-cloud-alibaba ,they reply me can report it here
thanks!
Issue Description
Type: bug report or feature request
Describe what happened (or what feature you want)
when I use
spring-cloud-starter-alibaba-sentine:2.2.9.RELEASE
withsentinel-transport-netty-http
in my spring-boot application , the jvm can not exit when I callactuator/shutdown
endpoint such as execcurl -X POST http://ip:port/actuator/shutdown
.This is because of
com.alibaba.csp.sentinel.transport.command.netty.HttpServer
thread has not closed when the application context closed.Describe what you expected to happen
Process finished with exit code 0
How to reproduce it (as minimally and precisely as possible)
run you local sentinel dashboard on port 8080
clone a simple demo such as
git clone git@github.com:tobrainto/sentinel-demo.git
Run it in Intelllij IDEA with args
exec
curl -X GET http://localhost:8090/hello
to trigger some init for sentinelexec
curl -X POST http://localhost:8090/actuator/shutdown
to shutdown the applicationyou cannot find the info which mean the process finished as blow.
Process finished with exit code 0
@PreDestroy private void destroy() { // Shutdown CommandCenter CommandCenter commandCenter = CommandCenterProvider.getCommandCenter(); if (commandCenter != null) { try { commandCenter.stop(); } catch (Exception e) { log.warn("Sentinel CommandCenter shutdown error :", e); } } }
java.lang.InterruptedException at java.base/java.lang.Object.wait(Native Method) at java.base/java.lang.Object.wait(Object.java:328) at io.netty.util.concurrent.DefaultPromise.await(DefaultPromise.java:253) at io.netty.channel.DefaultChannelPromise.await(DefaultChannelPromise.java:131) at io.netty.channel.DefaultChannelPromise.await(DefaultChannelPromise.java:30) at io.netty.util.concurrent.DefaultPromise.sync(DefaultPromise.java:404) at io.netty.channel.DefaultChannelPromise.sync(DefaultChannelPromise.java:119) at io.netty.channel.DefaultChannelPromise.sync(DefaultChannelPromise.java:30) at com.alibaba.csp.sentinel.transport.command.netty.HttpServer.start(HttpServer.java:86) at com.alibaba.csp.sentinel.transport.command.NettyHttpCommandCenter$1.run(NettyHttpCommandCenter.java:50) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834)