Class LockableFile

java.lang.Object
net.adoptopenjdk.icedteaweb.lockingfile.LockableFile

public class LockableFile extends Object
Process invalid input: '&' thread lockable access to a file. Creates file if it does not already exist.
  • Field Details

  • Constructor Details

    • LockableFile

      private LockableFile(File file)
  • Method Details

    • getInstance

      public static LockableFile getInstance(File file)
      Get a LockableFile for a given File. Ensures that we share the same instance for all threads.
      Parameters:
      file - the file to lock
      Returns:
      a LockableFile instance
    • isReadOnly

      private boolean isReadOnly(File file)
    • canWriteFile

      private boolean canWriteFile(File file)
    • canWriteParent

      private boolean canWriteParent(File file)
    • createParentDirIfMissing

      private void createParentDirIfMissing(File f)
    • createLockableFile

      private void createLockableFile()
    • getFile

      public File getFile()
      Get the file being locked.
      Returns:
      the file
    • isReadOnly

      public boolean isReadOnly()
      Returns:
      if the file is read only.
    • lock

      public void lock() throws IOException
      Lock access to the file.Lock is reentrant.
      Throws:
      IOException - if an I/O error occurs.
    • tryLock

      public boolean tryLock()
    • createFileIfMissing

      private void createFileIfMissing() throws IOException
      Throws:
      IOException
    • unlock

      public void unlock() throws IOException
      Unlock access to the file.Lock is reentrant. Does not do anything if not holding the lock.
      Throws:
      IOException - if an I/O error occurs.
    • isHeldByCurrentThread

      public boolean isHeldByCurrentThread()