Describe the bug
Since org.telegram.telegrambots.longpolling.util.LongPollingSingleThreadUpdateConsumer#updatesProcessorExecutor is a static variable, it's not safe to use LongPollingSingleThreadUpdateConsumer for two or more bots within the same application.
If bot_1 shuts down updatesProcessorExecutor, it's gets shut down for the bot_2 too.
To Reproduce
Minimal reproducible example: yvasyliev/telegram-bot-update-handler-demo
- Run the application:
./gradlew run --args="$BOT_TOKEN_1 $BOT_TOKEN_2"
- Send
/start and /stop commands to the first bot.
- Send
/start command to the second bot.
ER: the second bot should log incoming message
AR: the second bot does nothing
Expected behavior
The second bot should continue working regardless of whether the first bot shut down the executor service or not.
Suggested solution:
- Remove
updatesProcessorExecutor from LongPollingSingleThreadUpdateConsumer
- Rename
LongPollingUpdateConsumer to LongPollingUpdatesConsumer
- Rename
LongPollingSingleThreadUpdateConsumer to LongPollingUpdateConsumer
This way, it's up to user how they want to handle the updates (sync (default) or async).
Screenshots
Desktop (please complete the following information):
N/A
Smartphone (please complete the following information):
N/A
Additional context
Additional motivation: updatesProcessorExecutor is never shut down explicitly in the existing implementation which may result in resource leaks.