Closed dennissivia closed 8 months ago
Thanks for a sample!
There is a bunch of threads keeping application context alive:
"I/O dispatcher 6" #40 [47450] prio=5 os_prio=0 cpu=1.29ms elapsed=11.51s tid=0x00007f2e54035610 nid=47450 runnable [0x00007f2f00af6000]
java.lang.Thread.State: RUNNABLE
at sun.nio.ch.EPoll.wait(java.base@21.0.1/Native Method)
at sun.nio.ch.EPollSelectorImpl.doSelect(java.base@21.0.1/EPollSelectorImpl.java:121)
at sun.nio.ch.SelectorImpl.lockAndDoSelect(java.base@21.0.1/SelectorImpl.java:130)
- locked <0x000000044f033888> (a sun.nio.ch.Util$2)
- locked <0x000000044f033838> (a sun.nio.ch.EPollSelectorImpl)
at sun.nio.ch.SelectorImpl.select(java.base@21.0.1/SelectorImpl.java:142)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:255)
at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:591)
at java.lang.Thread.runWith(java.base@21.0.1/Thread.java:1596)
at java.lang.Thread.run(java.base@21.0.1/Thread.java:1583)
Excluding autoconfiguration from boot makes spring application context to close automatically:
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration
I can ask what is a boot team's view on this. One other thing is that if we should try some forceful exit as this is probably not a last time someone is seeing not-so-automatic-jvm-exit.
I completely forget that we already have a setting which does context close.
https://docs.spring.io/spring-shell/reference/customization/contextclose.html
That looks to work just fine with your sample.
Hi, thanks for the update. That setting does indeed fix the example app. However, on my real app the issue persists even with this setting. I will give it another look soon and if I can build an updated minimal case, I will reach out again.
Thanks for now 👍🏼
What
When adding
elasticsearch-rest-client
as a dependency to a fresh sping-shell project the application no longer exits normally. Instead you are forced to abort it with CTRL+C. The commands are executed normally but the shutdown does seem to be affected.Details
I created a new spring-shell application using the online spring initializer. The only added dependency was spring-shell-starter. Everything worked as expected. As soon I add the ES rest client dependency to the project, the problem occurs and the app does not properly exit/shut down. This happens without adding any code.
As soon as the dependency is removed, everything works as expected.
Expected behavior
Adding the dependency should not have any effect.
Reproducibility
The project is available at: https://github.com/dennissivia/shelltest and it can be reproduced in 100% of the cases. I tried this on windows and linux with the same result. I also tried openjdk 21 and graalvm jdk 21 with the same outcome.
I already tried to debug it but I am very new to Java and spring I quickly ran out of debugging ideas.