[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #5216: Refactor set executor
jdeppe-pivotal commented on a change in pull request #5216: URL: https://github.com/apache/geode/pull/5216#discussion_r440347391 ## File path: geode-redis/src/main/java/org/apache/geode/redis/internal/executor/key/RenameExecutor.java ## @@ -16,34 +16,35 @@ package org.apache.geode.redis.internal.executor.key; -import static org.apache.geode.redis.internal.RedisConstants.ERROR_NO_SUCH_KEY; - import java.util.List; +import org.apache.geode.redis.internal.RedisConstants; import org.apache.geode.redis.internal.data.ByteArrayWrapper; import org.apache.geode.redis.internal.executor.AbstractExecutor; -import org.apache.geode.redis.internal.executor.RedisResponse; +import org.apache.geode.redis.internal.netty.Coder; import org.apache.geode.redis.internal.netty.Command; import org.apache.geode.redis.internal.netty.ExecutionHandlerContext; public class RenameExecutor extends AbstractExecutor { - @Override - public RedisResponse executeCommand(Command command, - ExecutionHandlerContext context) { + public void executeCommand(Command command, ExecutionHandlerContext context) { Review comment: The changes here look like an incorrect merge perhaps. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [geode] jdeppe-pivotal commented on a change in pull request #5216: Refactor set executor
jdeppe-pivotal commented on a change in pull request #5216: URL: https://github.com/apache/geode/pull/5216#discussion_r436056100 ## File path: geode-redis/src/main/java/org/apache/geode/redis/internal/executor/string/SetExecutor.java ## @@ -68,72 +75,141 @@ private ByteArrayWrapper getValueToSet(List commandElems) { return new ByteArrayWrapper(value); } + private SetOptions parseOptionalParameters(List optionalParameterBytes) + throws IllegalArgumentException { - private SetOptions parseCommandElems(List commandElems) throws IllegalArgumentException { boolean keepTTL = false; SetOptions.Exists existsOption = SetOptions.Exists.NONE; long expiration = 0L; -for (int i = 3; i < commandElems.size(); i++) { - String current_arg = Coder.bytesToString(commandElems.get(i)).toUpperCase(); - switch (current_arg) { -case "KEEPTTL": - keepTTL = true; - break; -case "EX": - if (expiration != 0) { -throw new IllegalArgumentException(ERROR_SYNTAX); - } - i++; - expiration = parseExpirationTime(i, commandElems); - expiration = SECONDS.toMillis(expiration); - break; -case "PX": - if (expiration != 0) { -throw new IllegalArgumentException(ERROR_SYNTAX); - } - i++; - expiration = parseExpirationTime(i, commandElems); - break; -case "NX": - if (existsOption != SetOptions.Exists.NONE) { -throw new IllegalArgumentException(ERROR_SYNTAX); - } - existsOption = SetOptions.Exists.NX; - break; -case "XX": - if (existsOption != SetOptions.Exists.NONE) { -throw new IllegalArgumentException(ERROR_SYNTAX); - } - existsOption = SetOptions.Exists.XX; - break; -default: - throw new IllegalArgumentException(ERROR_SYNTAX); +List optionalParametersStrings = +optionalParameterBytes.stream() +.map(item -> Coder.bytesToString(item).toUpperCase()) +.collect(Collectors.toList()); + +throwExceptionIfUnknownParameter(optionalParametersStrings); +throwExceptionIfIncompatableParamaterOptions(optionalParametersStrings); + +if (optionalParametersStrings.contains("KEEPTL")) { + keepTTL = true; +} Review comment: This could be simplified to: ``` keepTTL = optionalParametersStrings.contains("KEEPTL"); ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org