diff --git a/src/main/java/redis/clients/jedis/resps/AccessControlLogEntry.java b/src/main/java/redis/clients/jedis/resps/AccessControlLogEntry.java index f95ade23cd..922d37fd6a 100644 --- a/src/main/java/redis/clients/jedis/resps/AccessControlLogEntry.java +++ b/src/main/java/redis/clients/jedis/resps/AccessControlLogEntry.java @@ -38,10 +38,6 @@ public class AccessControlLogEntry implements Serializable { private final long timestampCreated; private final long timestampLastUpdated; - /* - * Starting with Redis version 7.2.0: Added entry ID, timestamp created, and timestamp last updated. - * @see https://redis.io/docs/latest/commands/acl-log/ - */ public AccessControlLogEntry(Map map) { count = (long) map.get(COUNT); reason = (String) map.get(REASON); @@ -51,9 +47,10 @@ public AccessControlLogEntry(Map map) { ageSeconds = (Double) map.get(AGE_SECONDS); clientInfo = getMapFromRawClientInfo((String) map.get(CLIENT_INFO)); logEntry = map; - entryId = map.get(ENTRY_ID) == null ? 0L : (long) map.get(ENTRY_ID); - timestampCreated = map.get(TIMESTAMP_CREATED) == null ? 0L : (long) map.get(TIMESTAMP_CREATED); - timestampLastUpdated = map.get(TIMESTAMP_LAST_UPDATED) == null ? 0L : (long) map.get(TIMESTAMP_LAST_UPDATED); + // Redis 7.2 + entryId = map.containsKey(ENTRY_ID) ? (long) map.get(ENTRY_ID) : -1L; + timestampCreated = map.containsKey(TIMESTAMP_CREATED) ? (long) map.get(TIMESTAMP_CREATED) : -1L; + timestampLastUpdated = map.containsKey(TIMESTAMP_LAST_UPDATED) ? (long) map.get(TIMESTAMP_LAST_UPDATED) : -1L; } public long getCount() { diff --git a/src/main/java/redis/clients/jedis/resps/CommandInfo.java b/src/main/java/redis/clients/jedis/resps/CommandInfo.java index a8365a9806..c1360e97ec 100644 --- a/src/main/java/redis/clients/jedis/resps/CommandInfo.java +++ b/src/main/java/redis/clients/jedis/resps/CommandInfo.java @@ -136,12 +136,12 @@ public CommandInfo build(Object data) { long firstKey = LONG.build(commandData.get(3)); long lastKey = LONG.build(commandData.get(4)); long step = LONG.build(commandData.get(5)); - // (as of Redis 6.0) - List aclCategories = commandData.size()>=6?STRING_LIST.build(commandData.get(6)): Collections.emptyList(); - - // (as of Redis 7.0) - List tips = commandData.size()>=8?STRING_LIST.build(commandData.get(7)):Collections.emptyList(); - Map subcommands = commandData.size()>=10?COMMAND_INFO_RESPONSE.build(commandData.get(9)):Collections.EMPTY_MAP; + // Redis 6.0 + List aclCategories = commandData.size() >= 7 ? STRING_LIST.build(commandData.get(6)) : null; + // Redis 7.0 + List tips = commandData.size() >= 8 ? STRING_LIST.build(commandData.get(7)) : null; + Map subcommands = commandData.size() >= 10 + ? COMMAND_INFO_RESPONSE.build(commandData.get(9)) : null; return new CommandInfo(name, arity, flags, firstKey, lastKey, step, aclCategories, tips, subcommands); }