Skip to content

Commit

Permalink
Fix: client setname need ignore syntax error in redis4 (#3411)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangbodong22011 authored May 17, 2023
1 parent 8e6a709 commit 65d47fc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/redis/clients/jedis/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,14 @@ private void initializeFromClientConfig(JedisClientConfig config) {
if (obj instanceof JedisDataException) {
JedisDataException e = (JedisDataException)obj;
String errorMsg = e.getMessage().toUpperCase();
if (errorMsg.contains("UNKNOWN") ||
/**
* 1. Redis 4.0 and before, we need to ignore `Syntax error`.
* 2. Redis 5.0 and later, we need to ignore `Unknown subcommand error`.
* 3. Because Jedis allows Jedis jedis = new Jedis() in advance, and jedis.auth(password) later,
* we need to ignore `NOAUTH errors`.
*/
if (errorMsg.contains("SYNTAX") ||
errorMsg.contains("UNKNOWN") ||
errorMsg.contains("NOAUTH")) { // TODO: not filter out NOAUTH
// ignore
} else {
Expand Down

0 comments on commit 65d47fc

Please sign in to comment.