This is an automated email from the ASF dual-hosted git repository.

dschneider pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 7e222df  GEODE-8147: change redis DELETE and EXISTS to use 
Function+Delta (#5128)
7e222df is described below

commit 7e222dfb163a331181dee007c588f23b52249287
Author: Murtuza Boxwala <mboxw...@pivotal.io>
AuthorDate: Tue May 19 19:45:29 2020 -0400

    GEODE-8147: change redis DELETE and EXISTS to use Function+Delta (#5128)
    
    Co-authored-by: Sarah <mboxw...@pivotal.io>
    Co-authored-by: Sarah <sab...@pivotal.io>
---
 .../geode/redis/internal/GeodeRedisServer.java     |  2 +-
 .../geode/redis/internal/RedisCommandType.java     |  4 +-
 .../geode/redis/internal/RedisConstants.java       |  4 --
 .../geode/redis/internal/RegionProvider.java       | 17 +++-----
 .../redis/internal/executor/AbstractExecutor.java  |  3 +-
 .../redis/internal/executor/CommandFunction.java   | 30 +++++---------
 .../geode/redis/internal/executor/DelExecutor.java | 25 ++++--------
 .../redis/internal/executor/ExistsExecutor.java    |  9 ++---
 .../redis/internal/executor/FlushAllExecutor.java  |  2 +-
 .../redis/internal/executor/RedisKeyCommands.java  | 24 +++++++++++
 ....java => RedisKeyCommandsFunctionExecutor.java} | 38 ++++++++---------
 .../{ExistsExecutor.java => RedisKeyInRegion.java} | 47 ++++++++++++----------
 .../redis/internal/executor/RenameExecutor.java    |  2 +-
 .../sanctioned-geode-redis-serializables.txt       |  2 +-
 .../executor/AbstractExecutorJUnitTest.java        | 13 +++---
 .../executor/general/ExistsExecutorJUnitTest.java  | 13 +++---
 .../executor/string/DelExecutorJUnitTest.java      | 14 +++----
 17 files changed, 119 insertions(+), 130 deletions(-)

diff --git 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java
 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java
index 0e86551..28fb91b 100644
--- 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java
+++ 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/GeodeRedisServer.java
@@ -389,7 +389,7 @@ public class GeodeRedisServer {
       keyRegistrar.register(Coder.stringToByteArrayWrapper(STRING_REGION),
           RedisDataType.REDIS_PROTECTED);
 
-      CommandFunction.register();
+      CommandFunction.register(regionProvider);
     }
 
     checkForRegions();
diff --git 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisCommandType.java
 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisCommandType.java
index 49eca2d..af51524 100755
--- 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisCommandType.java
+++ 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisCommandType.java
@@ -158,8 +158,8 @@ public enum RedisCommandType {
    ***************************************/
 
   AUTH(new AuthExecutor()),
-  DEL(new DelExecutor()),
-  EXISTS(new ExistsExecutor()),
+  DEL(new DelExecutor(), new MinimumParameterRequirements(2)),
+  EXISTS(new ExistsExecutor(), new MinimumParameterRequirements(2)),
   EXPIRE(new ExpireExecutor()),
   EXPIREAT(new ExpireAtExecutor()),
   FLUSHALL(new FlushAllExecutor()),
diff --git 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisConstants.java 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisConstants.java
index 9f0365c..b290901 100644
--- 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisConstants.java
+++ 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/RedisConstants.java
@@ -78,12 +78,8 @@ public class RedisConstants {
     public static final String AUTH =
         "The wrong number of arguments or syntax was provided, the format for 
the AUTH command is \"AUTH password\"";
     public static final String DBSIZE = null;
-    public static final String DEL =
-        "The wrong number of arguments or syntax was provided, the format for 
the DEL command is \"DEL key [key ...]\"";
     public static final String ECHO =
         "The wrong number of arguments or syntax was provided, the format for 
the ECHO command is \"ECHO message\"";
-    public static final String EXISTS =
-        "The wrong number of arguments or syntax was provided, the format for 
the EXISTS command is \"EXISTS key\"";
     public static final String EXPIREAT =
         "The wrong number of arguments or syntax was provided, the format for 
the EXPIREAT command is \"EXPIREAT key timestamp\"";
     public static final String EXPIRE =
diff --git 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/RegionProvider.java 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/RegionProvider.java
index 98ff1ea..a761814 100644
--- 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/RegionProvider.java
+++ 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/RegionProvider.java
@@ -46,11 +46,9 @@ import 
org.apache.geode.management.internal.cli.commands.CreateRegionCommand;
 import org.apache.geode.management.internal.cli.result.model.ResultModel;
 import org.apache.geode.redis.internal.executor.ExpirationExecutor;
 import org.apache.geode.redis.internal.executor.ListQuery;
+import org.apache.geode.redis.internal.executor.RedisKeyCommands;
+import 
org.apache.geode.redis.internal.executor.RedisKeyCommandsFunctionExecutor;
 import org.apache.geode.redis.internal.executor.SortedSetQuery;
-import org.apache.geode.redis.internal.executor.hash.RedisHashCommands;
-import 
org.apache.geode.redis.internal.executor.hash.RedisHashCommandsFunctionExecutor;
-import org.apache.geode.redis.internal.executor.set.RedisSetCommands;
-import 
org.apache.geode.redis.internal.executor.set.RedisSetCommandsFunctionExecutor;
 
 /**
  * This class stands between {@link Executor} and {@link 
Cache#getRegion(String)}. This is needed
@@ -218,6 +216,7 @@ public class RegionProvider implements Closeable {
       if (!typeStoresDataInKeyRegistrar(type)) {
         keyRegistrar.unregister(key);
       }
+      RedisKeyCommands redisKeyCommands = new 
RedisKeyCommandsFunctionExecutor(dataRegion);
       try {
         if (type == RedisDataType.REDIS_STRING) {
           return stringsRegion.remove(key) != null;
@@ -225,14 +224,8 @@ public class RegionProvider implements Closeable {
           return hLLRegion.remove(key) != null;
         } else if (type == RedisDataType.REDIS_LIST || type == 
RedisDataType.REDIS_SORTEDSET) {
           return destroyRegion(key, type);
-        } else if (type == RedisDataType.REDIS_SET) {
-          RedisSetCommands redisSetCommands =
-              new RedisSetCommandsFunctionExecutor(dataRegion);
-          return redisSetCommands.del(key);
-        } else if (type == RedisDataType.REDIS_HASH) {
-          RedisHashCommands redisHashCommands =
-              new RedisHashCommandsFunctionExecutor(dataRegion);
-          return redisHashCommands.del(key);
+        } else if (type == RedisDataType.REDIS_SET || type == 
RedisDataType.REDIS_HASH) {
+          return redisKeyCommands.del(key);
         } else {
           return false;
         }
diff --git 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/AbstractExecutor.java
 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/AbstractExecutor.java
index 56425a6..540a6b0 100755
--- 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/AbstractExecutor.java
+++ 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/AbstractExecutor.java
@@ -91,10 +91,11 @@ public abstract class AbstractExecutor implements Executor {
     return context.getRegionProvider().getQuery(key, type);
   }
 
-  protected boolean removeEntry(ByteArrayWrapper key, RedisDataType type,
+  protected boolean removeEntry(ByteArrayWrapper key,
       ExecutionHandlerContext context) {
 
     RegionProvider rC = context.getRegionProvider();
+    RedisDataType type = context.getKeyRegistrar().getType(key);
     return rC.removeKey(key, type);
   }
 
diff --git 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/CommandFunction.java
 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/CommandFunction.java
index 6d37582..3030815 100644
--- 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/CommandFunction.java
+++ 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/CommandFunction.java
@@ -27,7 +27,7 @@ import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.redis.internal.ByteArrayWrapper;
 import org.apache.geode.redis.internal.RedisCommandType;
 import org.apache.geode.redis.internal.RedisData;
-import org.apache.geode.redis.internal.RedisDataType;
+import org.apache.geode.redis.internal.RegionProvider;
 import org.apache.geode.redis.internal.executor.set.RedisSetInRegion;
 import org.apache.geode.redis.internal.executor.set.SingleResultCollector;
 import org.apache.geode.redis.internal.executor.set.StripedExecutor;
@@ -39,10 +39,11 @@ public class CommandFunction extends 
SingleResultRedisFunction {
   public static final String ID = "REDIS_COMMAND_FUNCTION";
 
   private final transient StripedExecutor stripedExecutor;
+  private RegionProvider regionProvider;
 
-  public static void register() {
+  public static void register(RegionProvider regionProvider) {
     SynchronizedStripedExecutor stripedExecutor = new 
SynchronizedStripedExecutor();
-    FunctionService.registerFunction(new CommandFunction(stripedExecutor));
+    FunctionService.registerFunction(new CommandFunction(stripedExecutor, 
regionProvider));
   }
 
   public static <T> T execute(RedisCommandType command,
@@ -60,8 +61,10 @@ public class CommandFunction extends 
SingleResultRedisFunction {
   }
 
 
-  public CommandFunction(StripedExecutor stripedExecutor) {
+  public CommandFunction(StripedExecutor stripedExecutor,
+      RegionProvider regionProvider) {
     this.stripedExecutor = stripedExecutor;
+    this.regionProvider = regionProvider;
   }
 
   @Override
@@ -85,8 +88,10 @@ public class CommandFunction extends 
SingleResultRedisFunction {
         break;
       }
       case DEL:
-        RedisDataType delType = (RedisDataType) args[1];
-        callable = executeDel(key, localRegion, delType);
+        callable = () -> new RedisKeyInRegion(localRegion, 
regionProvider).del(key);
+        break;
+      case EXISTS:
+        callable = () -> new RedisKeyInRegion(localRegion, 
regionProvider).exists(key);
         break;
       case SMEMBERS:
         callable = () -> new RedisSetInRegion(localRegion).smembers(key);
@@ -139,17 +144,4 @@ public class CommandFunction extends 
SingleResultRedisFunction {
     return stripedExecutor.execute(key, callable);
   }
 
-
-  private Callable<Object> executeDel(ByteArrayWrapper key, Region localRegion,
-      RedisDataType delType) {
-    switch (delType) {
-      case REDIS_SET:
-        return () -> new RedisSetInRegion(localRegion).del(key);
-      case REDIS_HASH:
-        return () -> new RedisHashInRegion(localRegion).del(key);
-      default:
-        throw new UnsupportedOperationException("DEL does not support " + 
delType);
-    }
-  }
-
 }
diff --git 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/DelExecutor.java
 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/DelExecutor.java
index ca8ce2a..fd9db44 100755
--- 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/DelExecutor.java
+++ 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/DelExecutor.java
@@ -21,8 +21,6 @@ import org.apache.geode.redis.internal.ByteArrayWrapper;
 import org.apache.geode.redis.internal.Coder;
 import org.apache.geode.redis.internal.Command;
 import org.apache.geode.redis.internal.ExecutionHandlerContext;
-import org.apache.geode.redis.internal.RedisConstants.ArityDef;
-import org.apache.geode.redis.internal.RedisDataType;
 
 public class DelExecutor extends AbstractExecutor {
 
@@ -32,24 +30,15 @@ public class DelExecutor extends AbstractExecutor {
       throw new UnsupportedOperationInTransactionException();
     }
 
-    List<byte[]> commandElems = command.getProcessedCommand();
-    if (commandElems.size() < 2) {
-      
command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), 
ArityDef.DEL));
-      return;
-    }
-
-    int numRemoved = 0;
+    List<ByteArrayWrapper> commandElems = 
command.getProcessedCommandWrappers();
 
-    for (int i = 1; i < commandElems.size(); i++) {
-      byte[] byteKey = commandElems.get(i);
-      ByteArrayWrapper key = new ByteArrayWrapper(byteKey);
-      RedisDataType type = context.getKeyRegistrar().getType(key);
-      if (removeEntry(key, type, context)) {
-        numRemoved++;
-      }
-    }
+    long numRemoved = commandElems
+        .subList(1, commandElems.size())
+        .stream()
+        .filter((key) -> new RedisKeyCommandsFunctionExecutor(
+            context.getRegionProvider().getDataRegion()).del(key))
+        .count();
 
     
command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), 
numRemoved));
   }
-
 }
diff --git 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/ExistsExecutor.java
 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/ExistsExecutor.java
index 5f324e8..440c9ba 100755
--- 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/ExistsExecutor.java
+++ 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/ExistsExecutor.java
@@ -20,22 +20,19 @@ import org.apache.geode.redis.internal.ByteArrayWrapper;
 import org.apache.geode.redis.internal.Coder;
 import org.apache.geode.redis.internal.Command;
 import org.apache.geode.redis.internal.ExecutionHandlerContext;
-import org.apache.geode.redis.internal.RedisConstants.ArityDef;
 
 public class ExistsExecutor extends AbstractExecutor {
 
   @Override
   public void executeCommand(Command command, ExecutionHandlerContext context) 
{
     List<ByteArrayWrapper> commandElems = 
command.getProcessedCommandWrappers();
-    if (commandElems.size() < 2) {
-      
command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), 
ArityDef.EXISTS));
-      return;
-    }
+    RedisKeyCommands redisKeyCommands =
+        new 
RedisKeyCommandsFunctionExecutor(context.getRegionProvider().getDataRegion());
 
     long existsCount = commandElems
         .subList(1, commandElems.size())
         .stream()
-        .filter(key -> context.getKeyRegistrar().isRegistered(key))
+        .filter(key -> redisKeyCommands.exists(key))
         .count();
 
 
diff --git 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/FlushAllExecutor.java
 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/FlushAllExecutor.java
index 2ca7fbd..1b56158 100755
--- 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/FlushAllExecutor.java
+++ 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/FlushAllExecutor.java
@@ -37,7 +37,7 @@ public class FlushAllExecutor extends AbstractExecutor {
       try {
         ByteArrayWrapper skey = e.getKey();
         RedisDataType type = e.getValue().getType();
-        removeEntry(skey, type, context);
+        removeEntry(skey, context);
       } catch (EntryDestroyedException e1) {
         continue;
       }
diff --git 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RedisKeyCommands.java
 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RedisKeyCommands.java
new file mode 100644
index 0000000..2dfbf33
--- /dev/null
+++ 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RedisKeyCommands.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+
+package org.apache.geode.redis.internal.executor;
+
+import org.apache.geode.redis.internal.ByteArrayWrapper;
+
+public interface RedisKeyCommands {
+  boolean del(ByteArrayWrapper key);
+
+  boolean exists(ByteArrayWrapper key);
+}
diff --git 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/ExistsExecutor.java
 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RedisKeyCommandsFunctionExecutor.java
old mode 100755
new mode 100644
similarity index 50%
copy from 
geode-redis/src/main/java/org/apache/geode/redis/internal/executor/ExistsExecutor.java
copy to 
geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RedisKeyCommandsFunctionExecutor.java
index 5f324e8..8181dbf
--- 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/ExistsExecutor.java
+++ 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RedisKeyCommandsFunctionExecutor.java
@@ -12,33 +12,29 @@
  * or implied. See the License for the specific language governing permissions 
and limitations under
  * the License.
  */
-package org.apache.geode.redis.internal.executor;
 
-import java.util.List;
+package org.apache.geode.redis.internal.executor;
 
+import org.apache.geode.cache.Region;
 import org.apache.geode.redis.internal.ByteArrayWrapper;
-import org.apache.geode.redis.internal.Coder;
-import org.apache.geode.redis.internal.Command;
-import org.apache.geode.redis.internal.ExecutionHandlerContext;
-import org.apache.geode.redis.internal.RedisConstants.ArityDef;
+import org.apache.geode.redis.internal.RedisCommandType;
+import org.apache.geode.redis.internal.RedisData;
 
-public class ExistsExecutor extends AbstractExecutor {
-
-  @Override
-  public void executeCommand(Command command, ExecutionHandlerContext context) 
{
-    List<ByteArrayWrapper> commandElems = 
command.getProcessedCommandWrappers();
-    if (commandElems.size() < 2) {
-      
command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), 
ArityDef.EXISTS));
-      return;
-    }
+public class RedisKeyCommandsFunctionExecutor implements RedisKeyCommands {
+  private Region<ByteArrayWrapper, RedisData> region;
 
-    long existsCount = commandElems
-        .subList(1, commandElems.size())
-        .stream()
-        .filter(key -> context.getKeyRegistrar().isRegistered(key))
-        .count();
+  public RedisKeyCommandsFunctionExecutor(
+      Region<ByteArrayWrapper, RedisData> region) {
+    this.region = region;
+  }
 
+  @Override
+  public boolean del(ByteArrayWrapper key) {
+    return (boolean) CommandFunction.execute(RedisCommandType.DEL, key, new 
Object[] {}, region);
+  }
 
-    
command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), 
existsCount));
+  @Override
+  public boolean exists(ByteArrayWrapper key) {
+    return (boolean) CommandFunction.execute(RedisCommandType.EXISTS, key, new 
Object[] {}, region);
   }
 }
diff --git 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/ExistsExecutor.java
 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RedisKeyInRegion.java
old mode 100755
new mode 100644
similarity index 50%
copy from 
geode-redis/src/main/java/org/apache/geode/redis/internal/executor/ExistsExecutor.java
copy to 
geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RedisKeyInRegion.java
index 5f324e8..7a98f96
--- 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/ExistsExecutor.java
+++ 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RedisKeyInRegion.java
@@ -12,33 +12,38 @@
  * or implied. See the License for the specific language governing permissions 
and limitations under
  * the License.
  */
-package org.apache.geode.redis.internal.executor;
 
-import java.util.List;
+package org.apache.geode.redis.internal.executor;
 
+import org.apache.geode.cache.Region;
 import org.apache.geode.redis.internal.ByteArrayWrapper;
-import org.apache.geode.redis.internal.Coder;
-import org.apache.geode.redis.internal.Command;
-import org.apache.geode.redis.internal.ExecutionHandlerContext;
-import org.apache.geode.redis.internal.RedisConstants.ArityDef;
+import org.apache.geode.redis.internal.RedisData;
+import org.apache.geode.redis.internal.RegionProvider;
 
-public class ExistsExecutor extends AbstractExecutor {
-
-  @Override
-  public void executeCommand(Command command, ExecutionHandlerContext context) 
{
-    List<ByteArrayWrapper> commandElems = 
command.getProcessedCommandWrappers();
-    if (commandElems.size() < 2) {
-      
command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), 
ArityDef.EXISTS));
-      return;
-    }
+class RedisKeyInRegion {
+  private Region localRegion;
+  private RegionProvider regionProvider;
 
-    long existsCount = commandElems
-        .subList(1, commandElems.size())
-        .stream()
-        .filter(key -> context.getKeyRegistrar().isRegistered(key))
-        .count();
+  public RedisKeyInRegion(Region localRegion, RegionProvider regionProvider) {
+    this.localRegion = localRegion;
+    this.regionProvider = regionProvider;
+  }
 
+  public boolean del(ByteArrayWrapper key) {
+    RedisData redisData = (RedisData) localRegion.get(key);
+    if (redisData == null) {
+      return false;
+    }
+    switch (redisData.getType()) {
+      case REDIS_SET:
+      case REDIS_HASH:
+        return localRegion.remove(key) != null;
+      default:
+        return regionProvider.removeKey(key);
+    }
+  }
 
-    
command.setResponse(Coder.getIntegerResponse(context.getByteBufAllocator(), 
existsCount));
+  public boolean exists(ByteArrayWrapper key) {
+    return localRegion.containsKey(key);
   }
 }
diff --git 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RenameExecutor.java
 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RenameExecutor.java
index 80a6b2e..91731f8 100644
--- 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RenameExecutor.java
+++ 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/executor/RenameExecutor.java
@@ -67,7 +67,7 @@ public class RenameExecutor extends StringExecutor {
             Object value = region.get(key);
             context.getKeyRegistrar().register(newKey, redisDataType);
             region.put(newKey, value);
-            removeEntry(key, redisDataType, context);
+            removeEntry(key, context);
             break;
           case REDIS_HASH:
             // TODO this all needs to be done atomically. Add RENAME support 
to RedisHashCommands
diff --git 
a/geode-redis/src/main/resources/org/apache/geode/redis/internal/sanctioned-geode-redis-serializables.txt
 
b/geode-redis/src/main/resources/org/apache/geode/redis/internal/sanctioned-geode-redis-serializables.txt
index b7dbbed..d810d3b 100755
--- 
a/geode-redis/src/main/resources/org/apache/geode/redis/internal/sanctioned-geode-redis-serializables.txt
+++ 
b/geode-redis/src/main/resources/org/apache/geode/redis/internal/sanctioned-geode-redis-serializables.txt
@@ -17,7 +17,7 @@ org/apache/geode/redis/internal/RedisDataType$8,false
 org/apache/geode/redis/internal/RedisDataType$9,false
 
org/apache/geode/redis/internal/RedisDataTypeMismatchException,true,-2451663685348513870
 
org/apache/geode/redis/internal/RegionCreationException,true,8416820139078312997
-org/apache/geode/redis/internal/executor/CommandFunction,false
+org/apache/geode/redis/internal/executor/CommandFunction,false,regionProvider:org/apache/geode/redis/internal/RegionProvider
 org/apache/geode/redis/internal/executor/ListQuery,false
 org/apache/geode/redis/internal/executor/ListQuery$1,false
 org/apache/geode/redis/internal/executor/ListQuery$2,false
diff --git 
a/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/AbstractExecutorJUnitTest.java
 
b/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/AbstractExecutorJUnitTest.java
index ef2cca6..9754997 100644
--- 
a/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/AbstractExecutorJUnitTest.java
+++ 
b/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/AbstractExecutorJUnitTest.java
@@ -16,13 +16,14 @@
 package org.apache.geode.redis.internal.executor;
 
 import static org.junit.Assert.assertFalse;
+import static org.mockito.ArgumentMatchers.any;
 
 import org.junit.Test;
 import org.mockito.Mockito;
 
 import org.apache.geode.redis.internal.Coder;
 import org.apache.geode.redis.internal.ExecutionHandlerContext;
-import org.apache.geode.redis.internal.RedisDataType;
+import org.apache.geode.redis.internal.KeyRegistrar;
 import org.apache.geode.redis.internal.RegionProvider;
 import org.apache.geode.redis.internal.executor.string.SetExecutor;
 
@@ -36,17 +37,17 @@ public class AbstractExecutorJUnitTest {
     // setup mocks
     ExecutionHandlerContext context = 
Mockito.mock(ExecutionHandlerContext.class);
     RegionProvider rp = Mockito.mock(RegionProvider.class);
+    KeyRegistrar keyRegistrar = Mockito.mock(KeyRegistrar.class);
     Mockito.when(context.getRegionProvider()).thenReturn(rp);
-    Mockito.when(rp.removeKey(Mockito.any())).thenReturn(true);
+    Mockito.when(context.getKeyRegistrar()).thenReturn(keyRegistrar);
+    Mockito.when(rp.removeKey(any())).thenReturn(true);
 
     // Assert false to protected or null types
     
assertFalse(abstractExecutor.removeEntry(Coder.stringToByteArrayWrapper("junit"),
-        RedisDataType.REDIS_PROTECTED, context));
+        context));
 
     assertFalse(
-        abstractExecutor.removeEntry(Coder.stringToByteArrayWrapper("junit"), 
null, context));
-
-
+        abstractExecutor.removeEntry(Coder.stringToByteArrayWrapper("junit"), 
context));
 
   }
 
diff --git 
a/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/general/ExistsExecutorJUnitTest.java
 
b/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/general/ExistsExecutorJUnitTest.java
index 4d4dfac..f4aaf8c 100644
--- 
a/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/general/ExistsExecutorJUnitTest.java
+++ 
b/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/general/ExistsExecutorJUnitTest.java
@@ -15,7 +15,7 @@
 
 package org.apache.geode.redis.internal.executor.general;
 
-import static java.nio.charset.Charset.defaultCharset;
+import static org.assertj.core.api.AssertionsForClassTypes.catchThrowable;
 import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -29,8 +29,7 @@ import org.junit.Test;
 
 import org.apache.geode.redis.internal.Command;
 import org.apache.geode.redis.internal.ExecutionHandlerContext;
-import org.apache.geode.redis.internal.Executor;
-import org.apache.geode.redis.internal.executor.ExistsExecutor;
+import 
org.apache.geode.redis.internal.ParameterRequirements.RedisParametersMismatchException;
 
 public class ExistsExecutorJUnitTest {
 
@@ -47,15 +46,13 @@ public class ExistsExecutorJUnitTest {
 
   @Test
   public void calledWithTooFewCommandArguments_returnsError() {
-    Executor executor = new ExistsExecutor();
     List<byte[]> commandsAsBytesWithTooFewArguments = new ArrayList<>();
     commandsAsBytesWithTooFewArguments.add("EXISTS".getBytes());
     command = new Command(commandsAsBytesWithTooFewArguments);
 
+    Throwable thrown = catchThrowable(() -> command.execute(context));
 
-    executor.executeCommand(command, context);
-
-    assertThat(command.getResponse().toString(defaultCharset()))
-        .startsWith("-ERR The wrong number of arguments");
+    assertThat(thrown).hasMessageContaining("wrong number of arguments");
+    assertThat(thrown).isInstanceOf(RedisParametersMismatchException.class);
   }
 }
diff --git 
a/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/string/DelExecutorJUnitTest.java
 
b/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/string/DelExecutorJUnitTest.java
index 4f6570c..eeeb1e6 100644
--- 
a/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/string/DelExecutorJUnitTest.java
+++ 
b/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/string/DelExecutorJUnitTest.java
@@ -16,36 +16,34 @@
 
 package org.apache.geode.redis.internal.executor.string;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.AssertionsForClassTypes.catchThrowable;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.List;
 
 import io.netty.buffer.UnpooledByteBufAllocator;
+import org.assertj.core.api.AssertionsForClassTypes;
 import org.junit.Test;
 
 import org.apache.geode.redis.internal.Command;
 import org.apache.geode.redis.internal.ExecutionHandlerContext;
-import org.apache.geode.redis.internal.Executor;
-import org.apache.geode.redis.internal.executor.DelExecutor;
+import 
org.apache.geode.redis.internal.ParameterRequirements.RedisParametersMismatchException;
 
 
 public class DelExecutorJUnitTest {
 
   @Test
   public void calledWithTooFewOptions_returnsError() {
-    Executor delExecutor = new DelExecutor();
     List<byte[]> commandsAsBytes = new ArrayList<>();
     commandsAsBytes.add("DEL".getBytes());
     Command command = new Command(commandsAsBytes);
 
-    delExecutor.executeCommand(command, mockContext());
+    Throwable thrown = catchThrowable(() -> command.execute(mockContext()));
 
-    assertThat(command.getResponse().toString(Charset.defaultCharset()))
-        .startsWith("-ERR The wrong number of arguments or syntax was 
provided");
+    AssertionsForClassTypes.assertThat(thrown).hasMessageContaining("wrong 
number of arguments");
+    
AssertionsForClassTypes.assertThat(thrown).isInstanceOf(RedisParametersMismatchException.class);
   }
 
   public ExecutionHandlerContext mockContext() {

Reply via email to