Skip to content

[BUG] BlobContainerClient creates threads that aren't stopped on shutdown #34203

Open
@KatieKoslosky

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.commoncommon module used by all azure SDKs (e.g. client, Mgmt)customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions