Enable Slack#close() method to shutdown thread pools behind its SlackConfig #1060
Labels
bug
M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented
docs
M-T: Documentation work only
project:slack-api-client
project:slack-api-client
Milestone
Hello,
I am not sure whether this is a bug or really some misuse of the Slack SDK by my side.
I stumbled into an issue where a long-running JakartaEE-based application was getting overwhelmed with slack-api-metrics threads.
By the two week mark it had over 3900 of these threads, despite all of them being parked.
After some digging through the code and some debugging I realised that these threads are created everytime I instantiate a SlackConfig object which I did everytime I needed to call Slack API throught the SDK to send a message to a conversation.
Although I wasn't aware that these threads were created at all, I was expecting that by closing the Slack instance, these kind of resources could be freed or at least that the SDK realised that there were already some threads being used.
Below is the general aspect of the code I was using. Some time during the normal operation of the application there would be a need to send some messages, so I would invoke an EJB that would create a SlackConfig object (with slightly different settings), would get a Slack instance with that config and send the messages, closing it afterwards.
Reproducible in:
What happens here is:
Naturally, when I realised that 3 slack-api-metrics threads were being created everytime I created a SlackConfig object (one thread for MethodsConfig, AuditConfig and SCIMConfig) I solved the problem by just having a single SlackConfig object for the whole application that would be used whenever I needed a new Slack instance.
However, I am wondering if:
Thanks in advance.
The Slack SDK version
1.25.1
Java Runtime version
OpenJDK 64-Bit Server VM Corretto-11.0.16.9.1
OS info
Windows 10 Enterprise
Steps to reproduce:
Well, the kind of code I posted there should do it. Sorry for not providing a reproducer project.
Expected result:
Created metrics threads should be removed after the Slack instance is closed.
Actual result:
The JVM keeps the created threads and adds 3 more threads per each call
Requirements
N/A
The text was updated successfully, but these errors were encountered: