Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/io/lettuce/core/protocol/ReadOnlyCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* Contains all command names that are read-only commands.
*
* @author Mark Paluch
* @author Mingi Lee
* @since 6.2.5
*/
public class ReadOnlyCommands {
Expand Down Expand Up @@ -78,6 +79,7 @@ enum CommandName {
SDIFF, SINTER, SISMEMBER, SMISMEMBER, SMEMBERS, SRANDMEMBER, SSCAN, STRLEN, //
SUNION, TIME, TTL, TYPE, //
XINFO, XLEN, XPENDING, XRANGE, XREVRANGE, XREAD, //
JSON_ARRINDEX, JSON_ARRLEN, JSON_GET, JSON_MGET, JSON_OBJKEYS, JSON_OBJLEN, JSON_STRLEN, JSON_TYPE, //
ZCARD, ZCOUNT, ZLEXCOUNT, ZRANGE, //
ZRANDMEMBER, ZRANGEBYLEX, ZRANGEBYSCORE, ZRANK, ZREVRANGE, ZREVRANGEBYLEX, ZREVRANGEBYSCORE, ZREVRANK, ZSCAN, ZSCORE,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@
* Tests for {@link ClusterReadOnlyCommands}.
*
* @author Mark Paluch
* @author Mingi Lee
*/
@Tag(UNIT_TEST)
class ClusterReadOnlyCommandsUnitTests {

@Test
void testCount() {
assertThat(ClusterReadOnlyCommands.getReadOnlyCommands()).hasSize(84);
assertThat(ClusterReadOnlyCommands.getReadOnlyCommands()).hasSize(92);
}

@Test
void testResolvableCommandNames() {

for (ProtocolKeyword readOnlyCommand : ClusterReadOnlyCommands.getReadOnlyCommands()) {
assertThat(readOnlyCommand.toString()).isEqualTo(CommandType.valueOf(readOnlyCommand.toString()).name());
// Convert command string to enum name format (e.g., "JSON.GET" -> "JSON_GET")
String enumName = readOnlyCommand.toString().replace('.', '_');
assertThat(readOnlyCommand.toString()).isEqualTo(CommandType.valueOf(enumName).toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,14 +656,10 @@ private boolean noSaveInProgress() {

private boolean isCommandReadOnly(String commandName) {
List<Object> commandInfo = redis.commandInfo(commandName);
if (commandInfo == null || commandInfo.isEmpty()) {
throw new IllegalArgumentException("Command not found: " + commandName);
}
assumeTrue(commandInfo == null || commandInfo.isEmpty(), "Command " + commandName + " not found");

List<CommandDetail> details = CommandDetailParser.parse(commandInfo);
if (details.isEmpty()) {
throw new IllegalArgumentException("Command details could not be parsed: " + commandName);
}
assumeTrue(details.isEmpty(), "Command details could not be parsed: " + commandName);

CommandDetail detail = details.get(0);
return !detail.getFlags().contains(CommandDetail.Flag.WRITE);
Expand Down