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

spring boot 3.4.3 + TimedAspect causes thread to hang #44498

Open
180254 opened this issue Feb 28, 2025 · 0 comments
Open

spring boot 3.4.3 + TimedAspect causes thread to hang #44498

180254 opened this issue Feb 28, 2025 · 0 comments
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@180254
Copy link

180254 commented Feb 28, 2025

I have an application that stopped working correctly after updating to 3.4.3.
I have prepared a minimal app that reproduces the issue.

package com.example.demo;

import io.micrometer.core.annotation.Timed;
import io.micrometer.core.aop.TimedAspect;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

@SpringBootApplication
public class DemoApplication {

  public static void main(String[] args) {
    SpringApplication.run(DemoApplication.class, args);
  }

  @Bean
  public TimedAspect timedAspect() {
    return new TimedAspect();
  }

  @Service
  public static class DemoService {
    public DemoService(DemoFactory demoFactory) {
      Thread initThread = new Thread(demoFactory::initSomething);
      initThread.setName("DemoService-initThread");
      initThread.start();
    }
  }

  @Service
  public static class DemoFactory {
    @Timed(value = "init_timed")
    void initSomething() {
      System.out.println("INIT SOMETHING");
    }
  }
}

Output when running the application on 3.4.2:

 :: Spring Boot ::                (v3.4.2)

2025-02-28T22:08:46.129+01:00  INFO 53499 --- [           main] com.example.demo.DemoApplication         : Starting DemoApplication using Java 21.0.6 with PID 53499 (/somepath/spring-boot-issue-0/target/classes started by pedziwia in /somepath/spring-boot-issue-0)
2025-02-28T22:08:46.132+01:00  INFO 53499 --- [           main] com.example.demo.DemoApplication         : No active profile set, falling back to 1 default profile: "default"
2025-02-28T22:08:46.700+01:00  INFO 53499 --- [vice-initThread] o.s.b.f.s.DefaultListableBeanFactory     : Creating singleton bean 'timedAspect' in thread "DemoService-initThread" while other thread holds singleton lock for other beans [timedAspect]
2025-02-28T22:08:46.715+01:00  INFO 53499 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Creating singleton bean 'org.springframework.boot.actuate.autoconfigure.availability.AvailabilityHealthContributorAutoConfiguration' in thread "main" while other thread holds singleton lock for other beans []
INIT SOMETHING
2025-02-28T22:08:47.192+01:00  INFO 53499 --- [           main] com.example.demo.DemoApplication         : Started DemoApplication in 1.287 seconds (process running for 1.728)
Disconnected from the target VM, address: '127.0.0.1:58305', transport: 'socket'

Process finished with exit code 0

Output when running the application on 3.4.3:

 :: Spring Boot ::                (v3.4.3)

2025-02-28T22:09:46.824+01:00  INFO 53949 --- [           main] com.example.demo.DemoApplication         : Starting DemoApplication using Java 21.0.6 with PID 53949 (/somepath/spring-boot-issue-0/target/classes started by pedziwia in /somepath/spring-boot-issue-0)
2025-02-28T22:09:46.827+01:00  INFO 53949 --- [           main] com.example.demo.DemoApplication         : No active profile set, falling back to 1 default profile: "default"
2025-02-28T22:09:47.379+01:00  INFO 53949 --- [vice-initThread] o.s.b.f.s.DefaultListableBeanFactory     : Creating singleton bean 'timedAspect' in thread "DemoService-initThread" while other thread holds singleton lock for other beans [timedAspect]
2025-02-28T22:09:47.857+01:00  INFO 53949 --- [           main] com.example.demo.DemoApplication         : Started DemoApplication in 1.251 seconds (process running for 1.698)

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:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-actuator-autoconfigure</artifactId>
  <version>3.4.2</version>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-beans</artifactId>
  <version>6.2.2</version>
</dependency>

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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 28, 2025
@180254 180254 changed the title spring boot 3.4.3 messes something up with threads spring boot 3.4.3 + TimedAspect causes thread to hang Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants