at org.redisson.RedissonLock.lambda$unlockAsync 解锁异常

exception:java.lang.IllegalMonitorStateException: attempt to unlock lock, not locked by current thread by node id: 7b562ce4-4e16-4d39-a016-4f3118fe38a5 thread-id: 230 at org.redisson.RedissonLock.lambda$unlockAsync$3(RedissonLock.java:576) at org.redisson.misc.RedissonPromise.lambda$onComplete$0(RedissonPromise.java:187) at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:502) at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:495) at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:474) at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:415) at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:540) at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:529) at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:101) at org.redisson.misc.RedissonPromise.trySuccess(RedissonPromise.java:82) at org.redisson.command.CommandAsyncService.handleReference(CommandAsyncService.java:1101) at org.redisson.command.CommandAsyncService.handleSuccess(CommandAsyncService.java:1094) at org.redisson.command.CommandAsyncService.checkAttemptFuture(CommandAsyncService.java:1076) at org.redisson.command.CommandAsyncService.lambda$async$6(CommandAsyncService.java:800) at org.redisson.misc.RedissonPromise.lambda$onComplete$0(RedissonPromise.java:187) at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:502) at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:495) at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:474) at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:415) at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:540) at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:529) at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:101) at org.redisson.misc.RedissonPromise.trySuccess(RedissonPromise.java:82) at org.redisson.client.handler.CommandDecoder.completeResponse(CommandDecoder.java:440) at org.redisson.client.handler.CommandDecoder.handleResult(CommandDecoder.java:435) at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:366) at org.redisson.client.handler.CommandDecoder.decodeCommand(CommandDecoder.java:199) at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:139) at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:114) at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:502) at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:366) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:278) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337) at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337) at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337) at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:337) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1408) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:345) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:677) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:612) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:529) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:491) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:745) 

 

多线程情况下,加锁和解锁需要是同一线程才能解锁成功,这个异常是由于解锁线程不是加锁线程引起。

注意:finally中一定要用unlock()方法释放锁

 

参考文档:

https://blog.csdn.net/zyt807/article/details/86525084

https://www.whatyun.cn/article/294

你可能感兴趣的:(Java)