Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning with StackOverflowError during application shutdown #2891

Closed
mentamas opened this issue Jan 25, 2024 · 1 comment
Closed

Warning with StackOverflowError during application shutdown #2891

mentamas opened this issue Jan 25, 2024 · 1 comment

Comments

@mentamas
Copy link

When terminating Spring Boot Applications that use spring-cloud-stream:4.1.0, a StackOverflowError is thrown as the framework cannot stop some beans:

2024-01-25T19:01:02.950+01:00  WARN 33005 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Failed to stop bean 'solaceBinder_binderProducingContext'

java.lang.StackOverflowError: null
	at java.base/java.lang.invoke.BoundMethodHandle$Species_LJ.<init>(java/lang/invoke/BoundMethodHandle$Species_LJ) ~[na:na]
	at java.base/java.lang.invoke.BoundMethodHandle$Species_LJ.make(java/lang/invoke/BoundMethodHandle$Species_LJ) ~[na:na]
	at java.base/java.lang.invoke.BoundMethodHandle$Species_L.copyWithExtendJ(BoundMethodHandle.java:254) ~[na:na]
	at java.base/java.lang.invoke.LambdaFormEditor.bindArgumentJ(LambdaFormEditor.java:539) ~[na:na]
	at java.base/java.lang.invoke.BoundMethodHandle.bindArgumentJ(BoundMethodHandle.java:81) ~[na:na]
	at java.base/java.lang.invoke.MethodHandles.insertArgumentPrimitive(MethodHandles.java:5300) ~[na:na]
	at java.base/java.lang.invoke.MethodHandles.insertArguments(MethodHandles.java:5284) ~[na:na]
	at java.base/java.lang.invoke.StringConcatFactory.foldInLastMixers(StringConcatFactory.java:685) ~[na:na]
	at java.base/java.lang.invoke.StringConcatFactory.filterAndFoldInMixers(StringConcatFactory.java:657) ~[na:na]
	at java.base/java.lang.invoke.StringConcatFactory.generateMHInlineCopy(StringConcatFactory.java:587) ~[na:na]
	at java.base/java.lang.invoke.StringConcatFactory.makeConcatWithConstants(StringConcatFactory.java:365) ~[na:na]
	at java.base/java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:102) ~[na:na]
	at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:316) ~[na:na]
	at java.base/java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:274) ~[na:na]
	at java.base/java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:264) ~[na:na]
	at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:370) ~[spring-context-6.1.3.jar:6.1.3]
	at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:483) ~[spring-context-6.1.3.jar:6.1.3]
	at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
	at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:313) ~[spring-context-6.1.3.jar:6.1.3]
	at org.springframework.context.support.DefaultLifecycleProcessor.stop(DefaultLifecycleProcessor.java:186) ~[spring-context-6.1.3.jar:6.1.3]
	at org.springframework.context.support.AbstractApplicationContext.stop(AbstractApplicationContext.java:1523) ~[spring-context-6.1.3.jar:6.1.3]
	at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:357) ~[spring-context-6.1.3.jar:6.1.3]
	at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:483) ~[spring-context-6.1.3.jar:6.1.3]
	at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
	at org.

The StackOverflowError is thrown in spring-cloud-stream, regardless of which binder implementation is used in the application.
We have observed the problem both when using a Solace binder(4.1.0) and a custom binder.

The bug can be reproduced in any Spring Boot application that uses spring-cloud-stream version 4.1.0.
To make it easier to reproduce, I created a small test application with an integration test that demonstrates the issue using the Solace binder: https://github.com/mentamas/reproducers/tree/main/spring-cloud-stream-stackoverflowerror
(the test requires Docker as it uses Solace testcontainers)

The StackOverflowError is not reproducible with spring-cloud-stream:4.0.4.
I tried to analyse the problem a bit, in version 4.1.0 the propagation of shared beans has changed: #2728
Could this change have led to this new problem?

@sobychacko
Copy link
Contributor

@mentamas This bug we recently addressed on the snapshot (4.1.1-SNAPSHOT). The next point release will have the fix.

Please take a look at these related issues.

#2870
spring-projects/spring-framework#31982

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants