Skip to content

Incorrect TelegramLongPollingCommandBot class constructor implementation causing NPE in CommandRegistry.removeUsernameFromCommandIfNeeded(String command) method #770

@vikulin

Description

@vikulin

Incorrect TelegramLongPollingCommandBot class constructor implementation causing NPE in CommandRegistry.removeUsernameFromCommandIfNeeded(String command) method.
See the code line:

this.commandRegistry = new CommandRegistry(allowCommandsWithUsername, this.getBotUsername());

In time the TelegramLongPollingCommandBot contructor creates the instance method this.getBotUsername() returns null because all fields of implementing class have not been initialized yet. Fields initialization runs after super.TelegramLongPollingCommandBot invocation

Suggested fix: add String botUsername parameter in TelegramLongPollingCommandBot constructor passing to CommandRegistry instance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions