Class ReleaseLockException

All Implemented Interfaces:
Serializable

public class ReleaseLockException extends LockException
An ReleaseLockException indicates that the lock on an object can not be released since the releasing object does not have the lock. This is usually a programming error since unlocking should always have a corresponding lock some time before.
Author:
Ulrich Kreher
See Also:
  • Field Details

    • locked

      protected final boolean locked
      Whether the object is already locked (but not by the lock releasing object) or is not locked at all.
    • lockReleasingObject

      protected final Object lockReleasingObject
      The object trying to release the lock (but failing).
  • Constructor Details

    • ReleaseLockException

      public ReleaseLockException(Object lockedObject, boolean locked, Object lockReleasingObject, String lockType)
      Creates a new lock exception indicating that the designated lockReleasingObject can not unlock the designated lockedObject but the current lock owner is unknown or the object is not locked at all.
      Parameters:
      lockedObject - The object that is currently locked and that should be unlocked.
      locked - Whether the object is locked (and the lock owner is unknown).
      lockReleasingObject - The object that wanted to release the lock which led to the created exception.
      lockType - The type of the lock which can not be released.
    • ReleaseLockException

      public ReleaseLockException(Object lockedObject, Object lockOwner, Object lockReleasingObject, String lockType)
      Creates a new lock exception indicating that the designated lockReleasingObject can not unlock the designated lockedObject since it does not have the lock but the lockOwner has.
      Parameters:
      lockedObject - The object that is currently locked and that should be unlocked.
      lockOwner - The object that currently locks the object.
      lockReleasingObject - The object that wanted to release the lock which led to the created exception.
      lockType - The type of the lock which can not be released.
  • Method Details

    • isLocked

      public boolean isLocked()
      Wether the exception occurred due to another object having the lock (true) or having no lock at all (false).
      Returns:
      Whether the object is already locked by another object or not locked at all.
    • getLockReleasingObject

      public Object getLockReleasingObject()
      Returns the object that wants to release the lock.
      Returns:
      The object that wants to release the lock.
    • getMessage

      public String getMessage()
      Overrides:
      getMessage in class Throwable