Class OpenLockException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
OpenLockAcquireException, OpenLockTimeoutException

public class OpenLockException extends OpenException
Base Lock Exception for All Lock-Related Errors 所有锁相关错误的基础锁异常

Base exception class for all lock-related errors in the lock component, providing detailed error information including lock name and error type.

锁组件中所有锁相关错误的基础异常类,提供包括锁名称和错误类型的详细错误信息。

Features | 主要功能:

  • Lock name tracking - 锁名称跟踪
  • Error type classification - 错误类型分类
  • Cause chaining - 原因链
  • Component identification - 组件标识

Error Types | 错误类型:

  • GENERAL - General lock errors | 一般锁错误
  • TIMEOUT - Lock acquisition timeout | 锁获取超时
  • ACQUIRE - Lock acquisition failure | 锁获取失败
  • RELEASE - Lock release failure | 锁释放失败
  • EXPIRED - Lock expired | 锁已过期
  • NOT_HELD - Lock not held by thread | 线程未持有锁
  • DEADLOCK - Deadlock detected | 检测到死锁
  • INTERRUPTED - Thread interrupted | 线程被中断

Usage Examples | 使用示例:

// Catch lock operation failures
// 捕获锁操作失败
try {
    lock.lock();
} catch (OpenLockException e) {
    log.error("Lock failed: {}", e.getMessage());
}

Security | 安全性:

  • Thread-safe: Yes (immutable enum) - 线程安全: 是(不可变枚举)
  • Null-safe: Yes - 空值安全: 是
Since:
JDK 25, opencode-base-lock V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • OpenLockException

      public OpenLockException(String message)
      Constructs a new lock exception with message 使用消息构造新的锁异常
      Parameters:
      message - the error message | 错误消息
    • OpenLockException

      public OpenLockException(String message, Throwable cause)
      Constructs a new lock exception with message and cause 使用消息和原因构造新的锁异常
      Parameters:
      message - the error message | 错误消息
      cause - the cause | 原因
    • OpenLockException

      public OpenLockException(String message, String lockName, OpenLockException.LockErrorType errorType)
      Constructs a new lock exception with full details 使用完整详情构造新的锁异常
      Parameters:
      message - the error message | 错误消息
      lockName - the lock name | 锁名称
      errorType - the error type | 错误类型
    • OpenLockException

      public OpenLockException(String message, String lockName, OpenLockException.LockErrorType errorType, Throwable cause)
      Constructs a new lock exception with full details and cause 使用完整详情和原因构造新的锁异常
      Parameters:
      message - the error message | 错误消息
      lockName - the lock name | 锁名称
      errorType - the error type | 错误类型
      cause - the cause | 原因
  • Method Details

    • lockName

      public String lockName()
      Gets the name of the lock that caused the exception 获取导致异常的锁名称
      Returns:
      the lock name, or null if not specified | 锁名称,如果未指定则为null
    • errorType

      public OpenLockException.LockErrorType errorType()
      Gets the type of lock error that occurred 获取发生的锁错误类型
      Returns:
      the error type | 错误类型