Skip to content

Commit

Permalink
EnabledOnCommandRule get info only for requested command
Browse files Browse the repository at this point in the history
  • Loading branch information
ggivo committed Nov 11, 2024
1 parent a691416 commit 1895d09
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/test/java/io/redis/test/utils/EnabledOnCommandRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ private EnabledOnCommand getMethodAnnotation(Description description) {
*/
private boolean isCommandAvailable(Jedis jedisClient, String command, String subCommand) {
try {
Object raw = jedisClient.sendCommand(redis.clients.jedis.Protocol.Command.COMMAND);
Map<String, CommandInfo> commandList = BuilderFactory.COMMAND_INFO_RESPONSE.build(raw);
CommandInfo commandInfo = commandList.get(command.toLowerCase());
Map<String, CommandInfo> commandInfoMap= jedisClient.commandInfo(command);
CommandInfo commandInfo = commandInfoMap.get(command.toLowerCase());
if (commandInfo != null) {
// If a subCommand is provided, check for the subcommand under this command
if (subCommand != null && !subCommand.isEmpty()) {
Expand All @@ -117,8 +116,8 @@ private boolean isCommandAvailable(Jedis jedisClient, String command, String sub
}
return false; // Command not found
} catch (Exception e) {
logger.error("Error checking command '{}' availability: {}", command, e.getMessage());
return false;
String msg = String.format("Error found while EnableOnCommand for command '%s'", command);
throw new RuntimeException(msg, e);
}
}
};
Expand Down

0 comments on commit 1895d09

Please sign in to comment.