Description
Describe the bug
Since upgrading from Sprint Boot 2.5.6 to Spring Boot 2.7.9, I see numerous warning on application shutdown notifying me that threads have not been properly stopped. Testing showed this only occurred after the usage of BlobContainerClient, and I was able to produce a minimal example
I wonder if it's similar to #33873?
Exception or Stack Trace
2023-03-24 15:32:07.889 WARN 13988 --- [n(29)-127.0.0.1] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [parallel-2] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1081)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:750)
2023-03-24 15:32:07.890 WARN 13988 --- [n(29)-127.0.0.1] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [parallel-3] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1081)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:750)
2023-03-24 15:32:07.890 WARN 13988 --- [n(29)-127.0.0.1] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [parallel-4] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:750)
To Reproduce
Start the server. Run the code. Stop the Server. Messages are on application shutdown
Code Snippet
@configuration
public class AzureStorageBlobContainerClientConfig {
@Value("${blob.connection-string}")
String connectionString;
@Value("${blob.container-name}")
String containerName;
/**
* Builds the Azure Blob Container client to connect to Azure Blob Storage container
*
* @return A BlobContainerClientBuilder object
*/
@Bean
public BlobContainerClient getContainerClient() {
BlobContainerClientBuilder client = new BlobContainerClientBuilder();
client.connectionString(connectionString);
client.containerName(containerName);
return client.buildClient();
}
}
@RestController
public class GreetingController {
@Autowired
BlobContainerClient containerClient;
@GetMapping("/test")
public String test() {
ListBlobsOptions options = new ListBlobsOptions()
.setPrefix("test/")
.setDetails(new BlobListDetails()
.setRetrieveDeletedBlobs(false)
.setRetrieveSnapshots(false)
.setRetrieveTags(true));
Duration timeout = Duration.ofSeconds(5);
for (BlobItem blob : containerClient.listBlobs(options, timeout)) {
//iterate through list
}
return "Test";
}
}
Setup (please complete the following information):
- Library/Libraries: com.azure:azure-storage-blob:12.21.1
- Java version: 8
- Frameworks: spring-boot-starter-web:2.7.9
Activity