Search code examples
javaredisnettyredisson

Redisson not shutting down keeps Java VM open


I have the following simple code:

RedissonClient redisson = Redisson.create();

RMap<Object, Object> mymap = redisson.getMap("mymap");
mymap.put("field1", "value1");
mymap.put("field1", "value2");

redisson.shutdown();

logger.info("Here but JVM still runs after this line");

And the output is:

2018-02-01 15:24:14 INFO  Version:41 - Redisson 3.6.0
2018-02-01 15:24:14 INFO  MasterPubSubConnectionPool:144 - 1 connections initialized for /127.0.0.1:6379
2018-02-01 15:24:14 INFO  MasterConnectionPool:144 - 10 connections initialized for /127.0.0.1:6379
2018-02-01 15:24:17 INFO  RedisTest:21 - Here but JVM still runs after this line

What is other than shutdown needed for graceful shutdown? I got a thread dump and see the following non-daemon thread:

"ObjectCleanerThread" #13 prio=1 os_prio=31 tid=0x00007f885a05e800 nid=0xa803 in Object.wait() [0x00007000092cf000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x000000076ab108b0> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
    - locked <0x000000076ab108b0> (a java.lang.ref.ReferenceQueue$Lock)
    at io.netty.util.internal.ObjectCleaner$1.run(ObjectCleaner.java:52)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:748)

Solution

  • It seems that is a bug in netty: https://github.com/netty/netty/issues/7617

    The issue seems to be resolved but I guess it is not released yet.