Class OpenLockTimeoutException

All Implemented Interfaces:
OpenExceptionMeta, Serializable

public class OpenLockTimeoutException extends OpenLockException
Lock Timeout Exception for Acquisition Timeout 获取超时的锁超时异常

Thrown when lock acquisition times out before the lock could be obtained, providing information about the wait duration.

当锁获取在获得锁之前超时时抛出,提供有关等待时长的信息。

Features | 主要功能:

  • Wait time tracking - 等待时间跟踪
  • Lock name identification - 锁名称标识
  • Timeout-specific handling - 特定超时处理

Usage Examples | 使用示例:

try {
    lock.lock(Duration.ofSeconds(5));
} catch (OpenLockTimeoutException e) {
    Duration waited = e.waitTime();
    // Handle timeout | 处理超时
}

Security | 安全性:

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

    • OpenLockTimeoutException

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

      public OpenLockTimeoutException(String message, Duration waitTime)
      Constructs a new timeout exception with wait time 使用等待时间构造新的超时异常
      Parameters:
      message - the error message | 错误消息
      waitTime - the time spent waiting | 等待时间
    • OpenLockTimeoutException

      public OpenLockTimeoutException(String message, String lockName, Duration waitTime)
      Constructs a new timeout exception with lock name and wait time 使用锁名称和等待时间构造新的超时异常
      Parameters:
      message - the error message | 错误消息
      lockName - the lock name | 锁名称
      waitTime - the time spent waiting | 等待时间
  • Method Details

    • waitTime

      public Duration waitTime()
      Gets the time spent waiting before the timeout occurred 获取超时发生前的等待时间
      Returns:
      the time spent waiting, or null if not tracked | 等待时间,如果未跟踪则为null