The following line brought to a recursive call causing an infinite loop: https://github.com/spring-projects/spring-framework/blob/37fa82c578ae90b043d5cf7f7e216edb007cfc8a/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java#L483
This is what I see inside logs printing DEBUG level for this package (the last 5 line are replicated until StackOverflowError occur):
[o.s.c.support.DefaultLifecycleProcessor ] - Successfully stopped bean 'transaction-outcome_binderProducingContext' [o.s.c.support.DefaultLifecycleProcessor ] - Stopping beans in phase -2147482648 [o.s.cloud.stream.binding.BindingService ] - Trying to unbind 'errors-out-0', but no binding found. [o.s.c.support.DefaultLifecycleProcessor ] - Bean 'outputBindingLifecycle' completed its stop procedure [o.s.c.support.DefaultLifecycleProcessor ] - Stopping beans in phase -2147483647 [o.s.c.support.DefaultLifecycleProcessor ] - Bean 'springBootLoggingLifecycle' completed its stop procedure [o.s.c.support.DefaultLifecycleProcessor ] - Stopping beans in phase -2147483648 [o.s.c.support.DefaultLifecycleProcessor ] - Bean 'kafkaProducerFactory' completed its stop procedure [o.s.i.endpoint.EventDrivenConsumer ] - Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel [o.s.i.channel.PublishSubscribeChannel ] - Channel 'idpay-payment.errorChannel' has 0 subscriber(s). [o.s.c.support.DefaultLifecycleProcessor ] - Bean '_org.springframework.integration.errorLogger' completed its stop procedure [o.s.i.endpoint.EventDrivenConsumer ] - stopped bean '_org.springframework.integration.errorLogger' [o.s.c.support.DefaultLifecycleProcessor ] - Bean 'errors_integrationflow.org.springframework.integration.config.ConsumerEndpointFactoryBean#0' completed its stop procedure [o.s.i.endpoint.ReactiveStreamsConsumer ] - stopped bean 'errors_integrationflow.org.springframework.integration.config.ConsumerEndpointFactoryBean#0' [o.s.c.support.DefaultLifecycleProcessor ] - Bean 'transactionOutcome_integrationflow.org.springframework.integration.config.ConsumerEndpointFactoryBean#0' completed its stop procedure [o.s.i.endpoint.ReactiveStreamsConsumer ] - stopped bean 'transactionOutcome_integrationflow.org.springframework.integration.config.ConsumerEndpointFactoryBean#0' [o.s.c.support.DefaultLifecycleProcessor ] - Successfully stopped bean 'outerContext' [o.s.c.support.DefaultLifecycleProcessor ] - Successfully stopped bean 'kafka-errors_binderProducingContext' [o.s.c.support.DefaultLifecycleProcessor ] - Stopping beans in phase -2147482648 [o.s.c.support.DefaultLifecycleProcessor ] - Stopping beans in phase -2147483647 [o.s.c.support.DefaultLifecycleProcessor ] - Stopping beans in phase -2147483648 [o.s.c.support.DefaultLifecycleProcessor ] - Successfully stopped bean 'outerContext' [o.s.c.support.DefaultLifecycleProcessor ] - Successfully stopped bean 'kafka-errors_binderProducingContext' [o.s.c.support.DefaultLifecycleProcessor ] - Stopping beans in phase -2147482648 [o.s.c.support.DefaultLifecycleProcessor ] - Stopping beans in phase -2147483647 [o.s.c.support.DefaultLifecycleProcessor ] - Stopping beans in phase -2147483648 [o.s.c.support.DefaultLifecycleProcessor ] - Successfully stopped bean 'outerContext' [o.s.c.support.DefaultLifecycleProcessor ] - Successfully stopped bean 'kafka-errors_binderProducingContext' [o.s.c.support.DefaultLifecycleProcessor ] - Stopping beans in phase -2147482648 [o.s.c.support.DefaultLifecycleProcessor ] - Stopping beans in phase -2147483647 [o.s.c.support.DefaultLifecycleProcessor ] - Stopping beans in phase -2147483648 [o.s.c.support.DefaultLifecycleProcessor ] - Successfully stopped bean 'outerContext' [o.s.c.support.DefaultLifecycleProcessor ] - Successfully stopped bean 'kafka-errors_binderProducingContext' [o.s.c.support.DefaultLifecycleProcessor ] - Stopping beans in phase -2147482648 [o.s.c.support.DefaultLifecycleProcessor ] - Stopping beans in phase -2147483647 [o.s.c.support.DefaultLifecycleProcessor ] - Stopping beans in phase -2147483648 [o.s.c.support.DefaultLifecycleProcessor ] - Successfully stopped bean 'outerContext' [o.s.c.support.DefaultLifecycleProcessor ] - Successfully stopped bean 'kafka-errors_binderProducingContext'
I stopped there my application while in debug mode when the stacktrace lenght was > 500 seeing:
These are my phases:
While these are my lifecycleBeans
This is the stacktrace:
WARN [ionShutdownHook] [o.s.c.support.DefaultLifecycleProcessor ] - Failed to stop bean 'outerContext'
java.lang.StackOverflowError: null
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:494)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:313)
at org.springframework.context.support.DefaultLifecycleProcessor.stop(DefaultLifecycleProcessor.java:186)
at org.springframework.context.support.AbstractApplicationContext.stop(AbstractApplicationContext.java:1524)
at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:357)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:483)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:313)
at org.springframework.context.support.DefaultLifecycleProcessor.stop(DefaultLifecycleProcessor.java:186)
at org.springframework.context.support.AbstractApplicationContext.stop(AbstractApplicationContext.java:1524)
at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:357)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:483)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:313)
at org.springframework.context.support.DefaultLifecycleProcessor.stop(DefaultLifecycleProcessor.java:186)
at org.springframework.context.support.AbstractApplicationContext.stop(AbstractApplicationContext.java:1524)
at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:357)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:483)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:313)
at org.springframework.context.support.DefaultLifecycleProcessor.stop(DefaultLifecycleProcessor.java:186)
at org.springframework.context.support.AbstractApplicationContext.stop(AbstractApplicationContext.java:1524)
at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:357)
...
Comment From: snicoll
Thanks for the report but screenshots are not really actionable. Please move this to an application we can run ourselves to reproduce this. You can attach an issue as a zip here or push the code to a GitHub repository.
Comment From: antonioT90
Hi @snicoll, I reproduced the error on an empty project. It appears when there is a spring-cloud-stream's kafka binder (either Consumer or Producer)
You can find the code inside the following repo: https://github.com/antonioT90/spring-stackoverflowerror
Comment From: antonioT90
Moreover, It appears when using spring-cloud-dependencies 2023.0.0
, the previous 2022.0.4
is not showing the error
Comment From: snicoll
Thank you very much for the sample @antonioT90. I am debugging and I haven't tracked down the root cause of the issue yet, but the sample is super useful.
Comment From: snicoll
@sobychacko any idea what could have changed between those two SCS versions? I can see a cycle, potentially between created application contexts but I haven't been able to track down where the problem comes from.
Here are some logs https://gist.github.com/snicoll/a59d742675e18afc4ea81aeabc1fe48a. It looks like the stack overflow comes from stopping an ApplicationContext
that SCS has created with name kafka-consumer_binderProducingContext
.
Comment From: antonioT90
It is something that occurs when using the version org.springframework.cloud:spring-cloud-stream:4.1.0
, the version 4.0.4 of this library is not showing the exception
Comment From: sobychacko
Looks like this is related to an issue we resolved recently due to a regression. I am on PTO right now. I can take a look when I am back next week if there’s still something that is lingering in Spring Cloud Stream.
Comment From: antonioT90
@sobychacko I updated to org.springframework.cloud:spring-cloud-stream:4.1.1-SNAPSHOT
and the exception is not more occurring: thus the fix you made resolved also this issue.
Could you please tell me when the release 4.1.1 should be published?
Comment From: snicoll
Thanks for trying out @antonioT90!