Dankoy / jforwarder

Telegram bot for coub.com communities, tags and channels subscriptions.
https://t.me/coub_forwarder_bot
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Message locale can be null #120

Closed Dankoy closed 4 months ago

Dankoy commented 4 months ago

Describe the bug Message locale can be null. Some users has null locale. In that case default locale shall be used.

Exception example:

Caused by: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null
    at java.base/sun.util.locale.LocaleUtils.toLowerString(Unknown Source)
    at java.base/sun.util.locale.LanguageTag.parse(Unknown Source)
    at java.base/java.util.Locale.forLanguageTag(Unknown Source)
    at ru.dankoy.telegrambot.core.service.localeprovider.LocaleProviderImpl.getLocale(LocaleProviderImpl.java:17)
    at ru.dankoy.telegrambot.core.service.bot.commands.CommandsExtractorServiceImpl.getCommand(CommandsExtractorServiceImpl.java:31)
    at ru.dankoy.telegrambot.core.service.flow.BotCommandValidatorImpl.isValid(BotCommandValidatorImpl.java:29)

Expected behavior Class BotCOmmandValidator shall check locale on null, if true, get default locale. Or should it be implemented in LocaleProvider?