Skip to content

Commit 65d47fc

Browse files
Fix: client setname need ignore syntax error in redis4 (#3411)
1 parent 8e6a709 commit 65d47fc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main/java/redis/clients/jedis/Connection.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,14 @@ private void initializeFromClientConfig(JedisClientConfig config) {
398398
if (obj instanceof JedisDataException) {
399399
JedisDataException e = (JedisDataException)obj;
400400
String errorMsg = e.getMessage().toUpperCase();
401-
if (errorMsg.contains("UNKNOWN") ||
401+
/**
402+
* 1. Redis 4.0 and before, we need to ignore `Syntax error`.
403+
* 2. Redis 5.0 and later, we need to ignore `Unknown subcommand error`.
404+
* 3. Because Jedis allows Jedis jedis = new Jedis() in advance, and jedis.auth(password) later,
405+
* we need to ignore `NOAUTH errors`.
406+
*/
407+
if (errorMsg.contains("SYNTAX") ||
408+
errorMsg.contains("UNKNOWN") ||
402409
errorMsg.contains("NOAUTH")) { // TODO: not filter out NOAUTH
403410
// ignore
404411
} else {

0 commit comments

Comments
 (0)