spring-shell icon indicating copy to clipboard operation
spring-shell copied to clipboard

exception thrown and logged when using "exit" or "quit" command

Open BigMichi1 opened this issue 2 years ago • 3 comments

we build a small application on top of version 2.1.0 which works very well except when we use the "exit" or "quit" command. then the application prints out a lot of WARN entries where we have no idea how to get rid of them

start:

,--------.                 ,--.
'--.  .--'  ,---.   ,---.  |  |
   |  |    | .-. | | .-. | |  |
   |  |    ' '-' ' ' '-' ' |  |
   `--'     `---'   `---'  `--'

 
Powered by Spring Boot 2.7.2

2022-07-25 16:08:01.472  INFO 187306 --- [           main] d.c.b.a.c.i.Tool                         : Starting Tool using Java 17.0.3 on p52 with PID 187306 (/home/michaelcramer/cli/impl/build/libs/impl-0.0.1-SNAPSHOT.jar started by michaelcramer in /home/michaelcramer/cli/impl)
2022-07-25 16:08:01.493  INFO 187306 --- [           main] d.c.b.a.c.i.Tool                         : No active profile set, falling back to 1 default profile: "default"
2022-07-25 16:08:06.407  INFO 187306 --- [           main] o.s.c.c.s.GenericScope                   : BeanFactory id=3e1eea32-6ff2-39c7-afad-7c57e08b460b
2022-07-25 16:08:17.732  WARN 187306 --- [           main] o.jline                                  : The Parser of class org.springframework.shell.jline.ExtendedDefaultParser does not support the CompletingParsedLine interface. Completion with escaped or quoted words won't work correctly.
2022-07-25 16:08:17.925  INFO 187306 --- [           main] d.c.b.a.c.i.Tool                         : Started Tool in 18.013 seconds (JVM running for 20.847)
shell:>exit

and when now pressing enter a lot of these messages are written to the screen until we are back on the command line

2022-07-25 16:08:20.287  WARN 187306 --- [ionShutdownHook] s.c.a.AnnotationConfigApplicationContext : Exception thrown from ApplicationListener handling ContextClosedEvent

org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'org.springframework.shell.boot.LineReaderAutoConfiguration': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220) ~[spring-beans-5.3.22.jar!/:5.3.22]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.22.jar!/:5.3.22]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.22.jar!/:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.22.jar!/:5.3.22]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.getTargetBean(ApplicationListenerMethodAdapter.java:371) ~[spring-context-5.3.22.jar!/:5.3.22]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:336) ~[spring-context-5.3.22.jar!/:5.3.22]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:229) ~[spring-context-5.3.22.jar!/:5.3.22]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:166) ~[spring-context-5.3.22.jar!/:5.3.22]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.22.jar!/:5.3.22]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.22.jar!/:5.3.22]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.22.jar!/:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) ~[spring-context-5.3.22.jar!/:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:427) ~[spring-context-5.3.22.jar!/:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) ~[spring-context-5.3.22.jar!/:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1058) ~[spring-context-5.3.22.jar!/:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1021) ~[spring-context-5.3.22.jar!/:5.3.22]
	at org.springframework.cloud.context.named.NamedContextFactory.destroy(NamedContextFactory.java:99) ~[spring-cloud-context-3.1.3.jar!/:3.1.3]
	at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:213) ~[spring-beans-5.3.22.jar!/:5.3.22]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:587) ~[spring-beans-5.3.22.jar!/:5.3.22]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:559) ~[spring-beans-5.3.22.jar!/:5.3.22]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:1163) ~[spring-beans-5.3.22.jar!/:5.3.22]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:520) ~[spring-beans-5.3.22.jar!/:5.3.22]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:1156) ~[spring-beans-5.3.22.jar!/:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1106) ~[spring-context-5.3.22.jar!/:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1075) ~[spring-context-5.3.22.jar!/:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1021) ~[spring-context-5.3.22.jar!/:5.3.22]
	at org.springframework.boot.SpringApplicationShutdownHook.closeAndWait(SpringApplicationShutdownHook.java:145) ~[spring-boot-2.7.2.jar!/:2.7.2]
	at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
	at org.springframework.boot.SpringApplicationShutdownHook.run(SpringApplicationShutdownHook.java:114) ~[spring-boot-2.7.2.jar!/:2.7.2]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]

BigMichi1 avatar Jul 25 '22 14:07 BigMichi1

Do you have a sample to show? Looks like you have something from spring-cloud-context which possibly causes it as it's in a trace.

jvalkeal avatar Jul 25 '22 14:07 jvalkeal

you are right with the spring cloud idea. a sample project is here https://github.com/BigMichi1/spring-shell-openfeign. the more FeignClients are added, the more often the exception is logged. so if there is only one client one exception will be logged, if there are two clients 2 exceptions are logged

BigMichi1 avatar Jul 26 '22 07:07 BigMichi1

Right https://github.com/spring-cloud/spring-cloud-netflix/issues/1064 links to various other issues. Looks to be mostly cosmetic issue and you could just not log that warning.

Having said that it looks to be caused by onContextClosedEvent in LineReaderAutoConfiguration. Might be worth to rework saving jline history in some other ways.

jvalkeal avatar Jul 26 '22 07:07 jvalkeal