Search code examples
javadatabasejedis

"Jedis NOAUTH Authentication required"-spam after Java 16 upgrade


recently we migrated all our systems to java 16 due to customer requirements. So this is a unchangeable decision.

Now after the upgrade our jedis connection starts to spam the terminal with this error code:

[17:17:31 ERROR]: [redis.clients.jedis.JedisFactory] Error while validating pooled Jedis object.
redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.
        at redis.clients.jedis.Protocol.processError(Protocol.java:135) ~[?:?]
        at redis.clients.jedis.Protocol.process(Protocol.java:169) ~[?:?]
        at redis.clients.jedis.Protocol.read(Protocol.java:223) ~[?:?]
        at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:352) ~[?:?]
        at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:270) ~[?:?]
        at redis.clients.jedis.BinaryJedis.ping(BinaryJedis.java:379) ~[?:?]
        at redis.clients.jedis.JedisFactory.validateObject(JedisFactory.java:214) ~[?:?]
        at org.apache.commons.pool2.impl.GenericObjectPool.evict(GenericObjectPool.java:810) ~[?:?]
        at org.apache.commons.pool2.impl.BaseGenericObjectPool$Evictor.run(BaseGenericObjectPool.java:1160) ~[?:?]
        at org.apache.commons.pool2.impl.EvictionTimer$WeakRunner.run(EvictionTimer.java:213) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[?:?]
        at java.lang.Thread.run(Thread.java:831) [?:?]

System informations:

Debian buster (10) Java version: 16.0.1 Jedis version: 4.0.0-SNAPSHOT (Also tried with 3.6.x and 3.5.x) Redis version of remote server: 5.0.3 Commons pool: 2.9.0 (Also tried 2.5.0)

Code for connection:

Jedis jedis = null;
try {
    jedisPool = new JedisPool("XXX.XXX.XXX.XXX", XXX, 10000);
    jedis = MasterMind.getInstance().getJedisPool().getResource();
    jedis.auth("<SuperSafePass>");
    jedis.exists("test");
    Bukkit.getLogger().info("Connection build");
} catch (Exception e) {
    e.printStackTrace();
    Bukkit.getLogger().warning("Connection failure");
} finally {
    if (jedis != null)
        jedis.close();
}

As you see, I auth correctly. Connection gets build. After ~30 seconds it starts to spam the error (around 10 times every 30 seconds)


Solution

  • If Redis requires a password, the password has to be set when creating JedisPool, using one of the constructors like

    public JedisPool(final GenericObjectPoolConfig poolConfig, final String host, int port,
                     int timeout, final String password) { ... }
    

    Manually authenticating using

    jedis.auth(...);
    

    is not required anymore in that case.