Skip to content

Commit

Permalink
GEODE-9552: Change how Radish server shutdown/disconnect is handled (#…
Browse files Browse the repository at this point in the history
…6871)

- Close client connection on CancelException
 - Fix handling of RedisCommandParserException
 - Remove unused constants

Authored-by: Donal Evans <[email protected]>
  • Loading branch information
DonalEvans authored Sep 16, 2021
1 parent d58df40 commit d0113fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@ public class RedisConstants {
"The command received by GeodeRedisServer was improperly formatted";
public static final String SERVER_ERROR_MESSAGE =
"The server had an internal error please try again";
public static final String SERVER_ERROR_SHUTDOWN = "The server is shutting down";
public static final String ERROR_SELECT = "Only DB 0 supported";
public static final String ERROR_CURSOR = "invalid cursor";
public static final String ERROR_UNKNOWN_COMMAND =
"unknown command `%s`, with args beginning with: %s";
public static final String ERROR_OUT_OF_RANGE = "The number provided is out of range";
public static final String ERROR_NO_PASS = "Client sent AUTH, but no password is set";
public static final String ERROR_INVALID_PWD = "invalid password";
public static final String ERROR_NOT_AUTH = "NOAUTH Authentication required.";
public static final String ERROR_WRONG_TYPE =
"Operation against a key holding the wrong kind of value";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.DecoderException;
import org.apache.logging.log4j.Logger;
import org.apache.shiro.subject.Subject;

import org.apache.geode.cache.CacheClosedException;
import org.apache.geode.CancelException;
import org.apache.geode.cache.LowMemoryException;
import org.apache.geode.distributed.DistributedMember;
import org.apache.geode.internal.security.SecurityService;
Expand Down Expand Up @@ -163,13 +162,15 @@ private RedisResponse getExceptionResponse(ChannelHandlerContext ctx, Throwable
return RedisResponse.error(rootCause.getMessage());
} else if (rootCause instanceof LowMemoryException) {
return RedisResponse.oom(RedisConstants.ERROR_OOM_COMMAND_NOT_ALLOWED);
} else if (rootCause instanceof DecoderException
&& rootCause.getCause() instanceof RedisCommandParserException) {
} else if (rootCause instanceof RedisCommandParserException) {
return RedisResponse
.error(RedisConstants.PARSING_EXCEPTION_MESSAGE + ": " + rootCause.getMessage());
} else if (rootCause instanceof InterruptedException
|| rootCause instanceof CacheClosedException) {
return RedisResponse.error(RedisConstants.SERVER_ERROR_SHUTDOWN);
} else if (rootCause instanceof InterruptedException || rootCause instanceof CancelException) {
logger
.warn("Closing Redis client connection because the server doing this operation departed: "
+ rootCause.getMessage());
channelInactive(ctx);
return null;
} else {
if (logger.isErrorEnabled()) {
logger.error("GeodeRedisServer-Unexpected error handler for {}", ctx.channel(), rootCause);
Expand Down

0 comments on commit d0113fc

Please sign in to comment.