Azure / azure-service-bus-java

☁️ Java client library for Azure Service Bus
https://azure.microsoft.com/services/service-bus
MIT License
60 stars 58 forks source link

Memory leak regarding threads started by SubscriptionClient #319

Open MStumpp opened 5 years ago

MStumpp commented 5 years ago

Describe the bug When undeploying a Tomcat8 application (war), Tomcat warns about a memory leak regarding threads which could not be stopped. It happens even SubscriptionClient.close() is called.

To Reproduce Create a war application, which set up a SubscriptionClient and registers a MessageHandler and configures n (128 in my case) concurrent calls (MessageHandlerOptions).

Code can be taken from: https://github.com/Azure/azure-service-bus/blob/master/samples/Java/azure-servicebus/TopicsGettingStarted/src/main/java/com/microsoft/azure/servicebus/samples/topicsgettingstarted/TopicsGettingStarted.java

Expected behavior All threads started by Azure Service Bus lib are terminated when calling SubscriptionClient.close(). No warnings are shown.

Observed behavior org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [...] appears to have started a thread named [...] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:

Environment (please complete the following information):

yvgopal commented 5 years ago

what is the name of the thread? That may help me identify the issue, without having to deploy a sample application to a web server.