简体   繁体   中英

java.lang.IllegalMonitorStateException: Current thread is not owner of the lock

I upgraded my hazelcast from 2.4 to 3.3, but this exception occurred.

13:12:51,269 [Thread-21]: ERROR xx.xx.xxThread:1783 - run:
java.lang.IllegalMonitorStateException: Current thread is not owner of the lock! -> <not-locked>
    at com.hazelcast.concurrent.lock.operations.UnlockOperation.ensureUnlocked(UnlockOperation.java:71)
    at com.hazelcast.concurrent.lock.operations.UnlockOperation.unlock(UnlockOperation.java:65)
    at com.hazelcast.concurrent.lock.operations.UnlockOperation.run(UnlockOperation.java:57)
    at com.hazelcast.spi.impl.BasicOperationService$OperationHandler.handle(BasicOperationService.java:699)
    at com.hazelcast.spi.impl.BasicOperationService$OperationHandler.access$400(BasicOperationService.java:675)
    at com.hazelcast.spi.impl.BasicOperationService$OperationPacketHandler.handle(BasicOperationService.java:649)
    at com.hazelcast.spi.impl.BasicOperationService$OperationPacketHandler.handle(BasicOperationService.java:604)
    at com.hazelcast.spi.impl.BasicOperationService$OperationPacketHandler.access$1400(BasicOperationService.java:591)
    at com.hazelcast.spi.impl.BasicOperationService$BasicDispatcherImpl.dispatch(BasicOperationService.java:543)
    at com.hazelcast.spi.impl.BasicOperationScheduler$OperationThread.process(BasicOperationScheduler.java:439)
    at com.hazelcast.spi.impl.BasicOperationScheduler$OperationThread.doRun(BasicOperationScheduler.java:433)
    at com.hazelcast.spi.impl.BasicOperationScheduler$OperationThread.run(BasicOperationScheduler.java:408)
    at ------ End remote and begin local stack-trace ------.(Unknown Source)
    at com.hazelcast.spi.impl.BasicInvocationFuture.resolveApplicationResponse(BasicInvocationFuture.java:356)
    at com.hazelcast.spi.impl.BasicInvocationFuture.resolveApplicationResponseOrThrowException(BasicInvocationFuture.java:289)
    at com.hazelcast.spi.impl.BasicInvocationFuture.get(BasicInvocationFuture.java:181)
    at com.hazelcast.spi.impl.BasicInvocationFuture.get(BasicInvocationFuture.java:160)
    at com.hazelcast.spi.impl.BasicInvocationFuture.getSafely(BasicInvocationFuture.java:172)
    at com.hazelcast.concurrent.lock.LockProxySupport.unlock(LockProxySupport.java:126)
    at com.hazelcast.concurrent.lock.LockProxy.unlock(LockProxy.java:99)
    at activesync.server.CheckLoginsThread.run(CheckLoginsThread.java:1552)

The change for getLock in 3.3 is that the String is required as the parameter in new version. I just changed it from Object to String, nothing else is changed. The code is as below:

Map logins = MyHazelcast.getMap("logins");
Lock lock = MyHazelcast.getLock("logins");
lock.lock();
try
{
     // do something...
}
finally
{
    lock.unlock();
}  

Is this caused by the new version or I missed something?

> Current thread is not owner of the lock! -> <not-locked>

"not locked" means that lock with given key wasn't found. Is it possible that lock with key "logins" is used in another place?

Maybe you release the lock somewhere inside your code?

I would start with unique key name for this lock.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM