Why LockListener is not public
Describe the bug
interface LockListener { /**
- call back called when the lock is preempted */ void onCleanupNotification(); } This interface should be public
To Reproduce
When not set LockListener, try to lock with higher priority, it throw "Cleanup has not been finished by lock owner"
Expected behavior
interface LockListener should be public, or when not set LockListener, it should be pass
Additional context
Add any other context about the problem here.
Thanks @hungvm90. Will let original author to fix it.
@mgao0
@zhangmeng916 Is not set LockListener an expected user behavior? I tried making LockListener public, but it didn't solve the problem because not setting LockListener will cause NPE, no matter if the interface is public or not.
@hungvm90 The LockListener needs to be set for the lock to be able to work, since it listens on Zookeeper once there is any change in the lock path.
Sorry, my description for this issue is not correct, but I think LockListener should be public. For example, I implement lock with priority, so I need ack when I lose this lock. But LockListener is not public, so I can't implement it.
lock = new ZKDistributedNonblockingLock.Builder() .setLockScope(new HelixLockScope(HelixLockScope.LockScopeProperty.RESOURCE, pathKeys)) .setZkAddress(zooKeeperHost) .setUserId(instanceName) .setTimeout(timeout) .setPriority(LOCK_LOW_PRIORITY) .setLockListener(new LockListener() { @Override public void onCleanupNotification() { for (LockLoseListener listener : listeners) { listener.onLoseLock(lock); } } }) .setLockMsg(String.format("Lock %s from %s", resource, instanceName)) .build();