Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8293469

lock(0, 0, true) throws OverlappingFileLockException

XMLWordPrintable

    • 19
    • x86_64
    • windows_10

      ADDITIONAL SYSTEM INFORMATION :
      openjdk version "19" 2022-09-20
      OpenJDK Runtime Environment (build 19+36-2238)
      OpenJDK 64-Bit Server VM (build 19+36-2238, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      Creating of a shared lock on a file to prevent a delete of the file in different threads results in an OverlappingFileLockException. The sense of a shared lock is the possibility to create multiple locks on the same file from different threads or different applications. This is not possible anymore.

      If shared means another thing here then is should be better documented.

      REGRESSION : Last worked in version 17.0.4.1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the follow code:

      FileLock lock1 = new RandomAccessFile( anyFile, "rw" ).getChannel().lock( 0, 0, true );
      FileLock lock2 = new RandomAccessFile( anyFile, "rw" ).getChannel().lock( 0, 0, true );


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Creating two shared locks also in one Java VM.
      ACTUAL -
      java.nio.channels.OverlappingFileLockException
      at java.base/sun.nio.ch.FileLockTable.checkList(FileLockTable.java:229)
      at java.base/sun.nio.ch.FileLockTable.add(FileLockTable.java:123)
      at java.base/sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:1470)


      FREQUENCY : always


            bpb Brian Burkhalter
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: