You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a TwitchClientBuilder and including .withAutoSaveConfiguration(false), I will get a stack trace when trying to register a command in said TwitchClient's CommandHandler. The stack trace only occurs when trying to register an instance of a Command (i.e. TestCommand()), not when registering the class (TestCommand.class).
Triggers stack trace
TestCommand command = new TestCommand();
twitchClient.getCommandHandler().registerCommand(command);
Expected behavior:
The Command should register with not stack trace.
Actual behavior:
The Command is registered to the CommandHandler and I am able to use it in Twitch chat, however I get a stack trace during the registration.
I believe this is a bug because of the logic of the method where the exception occurs.
public void saveDynamicCommands() {
try {
// Get all Dynamic Commands
List<Command> commandList = getCommandMap().values().stream().filter(e -> e instanceof DynamicCommand).collect(Collectors.toList());
// Save List to File
ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(getCommandSaveFile(), commandList);
} catch (Exception ex) {
ex.printStackTrace();
}
}
The exception occurs at the line mapper.writeValue(getCommandSaveFile(), commandList); (line 283). A NullPointerException is thrown because there is no command save file because saving configurations was disabled when creating the TwitchClient instance. If users are given the option to disable saving configurations, then either the exception should be handled quietly or there should be logic to check the user's preferences before attempting to write to the file and printing the error.
I tried to test this theory by enabling saving configurations (.withAutoSaveConfiguration(true)) and repeating the process. As expected, no stack trace occurred, supporting my belief that this is a bug.
It's entirely possible that I am using this library in an unintended manner, however if I understand what is happening correctly then I think this is an issue.
The text was updated successfully, but these errors were encountered:
Prerequisites
Description
When creating a TwitchClientBuilder and including .withAutoSaveConfiguration(false), I will get a stack trace when trying to register a command in said TwitchClient's CommandHandler. The stack trace only occurs when trying to register an instance of a Command (i.e. TestCommand()), not when registering the class (TestCommand.class).
Triggers stack trace
No stack trace
Steps to Reproduce
Expected behavior:
The Command should register with not stack trace.
Actual behavior:
The Command is registered to the CommandHandler and I am able to use it in Twitch chat, however I get a stack trace during the registration.
Stacktrace (if applicable):
https://hastebin.com/ehiwuxelar.xml
Version affected:
0.10.1
Additional Information
I believe this is a bug because of the logic of the method where the exception occurs.
The exception occurs at the line
mapper.writeValue(getCommandSaveFile(), commandList);
(line 283). A NullPointerException is thrown because there is no command save file because saving configurations was disabled when creating the TwitchClient instance. If users are given the option to disable saving configurations, then either the exception should be handled quietly or there should be logic to check the user's preferences before attempting to write to the file and printing the error.I tried to test this theory by enabling saving configurations (
.withAutoSaveConfiguration(true)
) and repeating the process. As expected, no stack trace occurred, supporting my belief that this is a bug.It's entirely possible that I am using this library in an unintended manner, however if I understand what is happening correctly then I think this is an issue.
The text was updated successfully, but these errors were encountered: