Redisson不关闭使Java VM保持打开状态

时间:2018-02-02 06:33:31

标签: java redis netty redisson

我有以下简单的代码:

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");

输出是:

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

正常关机需要关机以外的什么?我有一个线程转储,并看到以下非守护程序线程:

"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)

1 个答案:

答案 0 :(得分:3)

似乎这是netty中的一个错误:https://github.com/netty/netty/issues/7617

这个问题似乎已经解决,但我想它还没有发布。