Class ConfigFileLock

java.lang.Object
com.atlassian.secrets.service.lock.ConfigFileLock

public class ConfigFileLock extends Object
This class provides utility methods for file locking and dealing with quirks of Underlock.
If the application is forcefully terminated, the lock file may not be removed. This will then prevent the application from starting up again. This class provides a method to clean up stale lock files and execute operations under a lock.
  • Field Details

    • LOCK_TIMEOUT_SYS_PROP

      public static final String LOCK_TIMEOUT_SYS_PROP
      See Also:
    • LOCK_TIMEOUT_DEFAULT_IN_MS

      public static final Long LOCK_TIMEOUT_DEFAULT_IN_MS
    • STALE_LOCK_DURATION_SYS_PROP

      public static final String STALE_LOCK_DURATION_SYS_PROP
      See Also:
    • STALE_LOCK_DURATION_IN_MS

      public static final Long STALE_LOCK_DURATION_IN_MS
    • LOCK_FILE_SUFFIX

      public static final String LOCK_FILE_SUFFIX
      See Also:
  • Constructor Details

    • ConfigFileLock

      public ConfigFileLock(Path fileToLock)
  • Method Details

    • cleanupStaleLockFile

      public void cleanupStaleLockFile()
      Cleans up stale lock files. The lock file is considered stale if it has not been modified for a certain duration. This duration is specified by the system property "atlassian.secret.service.lock.stale.age" in milliseconds and defaults to 1 minute.
    • underLock

      public void underLock(Runnable action)
      Executes an action under a file lock.
      Parameters:
      action - the action to execute