-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
spring boot 3.4.3 + TimedAspect causes thread to hang #34522
Comments
Thank you for sharing the sample, @180254. After reviewing your issue, I can confirm that it indeed stopped working in 3.4.3. While debugging, I discovered "DemoService-initThread" spring-projects/spring-boot#52 [37635] prio=5 os_prio=31 cpu=1.56ms elapsed=2.87s tid=0x0000000138981600 nid=37635 waiting on condition [0x000000017a4d1000]
java.lang.Thread.State: WAITING (parking)
at jdk.internal.misc.Unsafe.park(java.base@21.0.5/Native Method)
- parking to wait for <0x0000000500805508> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(java.base@21.0.5/LockSupport.java:371)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(java.base@21.0.5/AbstractQueuedSynchronizer.java:519)
at java.util.concurrent.ForkJoinPool.unmanagedBlock(java.base@21.0.5/ForkJoinPool.java:3780)
at java.util.concurrent.ForkJoinPool.managedBlock(java.base@21.0.5/ForkJoinPool.java:3725)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(java.base@21.0.5/AbstractQueuedSynchronizer.java:1712)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:313)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.aop.aspectj.annotation.BeanFactoryAspectInstanceFactory.getAspectInstance(BeanFactoryAspectInstanceFactory.java:90)
at org.springframework.aop.aspectj.annotation.LazySingletonAspectInstanceFactoryDecorator.getAspectInstance(LazySingletonAspectInstanceFactoryDecorator.java:56)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:642)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:632)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:71)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:727)
at com.example.demo.DemoApplication$DemoFactory$$SpringCGLIB$$0.initSomething(<generated>)
at com.example.demo.DemoApplication$DemoService$$Lambda/0x000000d801306278.run(Unknown Source)
at java.lang.Thread.runWith(java.base@21.0.5/Thread.java:1596)
at java.lang.Thread.run(java.base@21.0.5/Thread.java:1583)
|
Thanks Here are some new observations: Adding a thread that keeps the application running fixes the DemoService in the sample application. However, this is not the case in general; my production application, where I encountered the issue, is a web application. I am unable to find a minimal web application that reproduces the issue. @Service
public static class KeepAppWorking {
public KeepAppWorking() {
try {
System.out.println("KeepAppWorking");
CountDownLatch latch = new CountDownLatch(1);
latch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} or <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> -- The spring-beans in the current snapshot version do not help; the sample app still doesn't work. <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>6.2.4-20250301.124437-29</version>
</dependency> -- Explicitly adding a dependency on TimedAspect makes the sample app work. Preliminary tests indicate that my production application also starts working after applying such a change. public DemoFactory(TimedAspect timedAspect) {} -- You are right, the change in DefaultSingletonBeanRegistry is causing the issue. Reverting org.springframework.beans.factory.support.DefaultSingletonBeanRegistry class to version 6.2.2 makes the sample app work. Preliminary tests indicate that my production application also starts working after applying such a change. |
The specific problem here seems to be the attempt to concurrently initialize the |
@180254 the latest 6.2.4 snapshot contains that revision now. Please give it another try! As for an explicit dependency on the |
I am pleased to say that the new spring-beans prerelease version makes both the sample demo app and my main application work. <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.3</version>
<relativePath/>
</parent> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>6.2.4-20250301.213415-30</version>
</dependency> Thanks for addressing the problem promptly. |
Good to hear! Thanks for the immediate feedback. |
I have an application that stopped working correctly after updating to 3.4.3.
I have prepared a minimal app that reproduces the issue.
Output when running the application on 3.4.2:
Output when running the application on 3.4.3:
The process does not terminate, it hangs forever and "INIT SOMETHING" is never printed.
I compared the classpath and found that downgrading the versions of two dependencies:
allows the program to start and work correctly again.
I have prepared a repository with a minimal app in Docker that reproduces this issue.
https://github.com/180254/spring-boot-issue-44498
The text was updated successfully, but these errors were encountered: