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

(fc) lock/tryLock methods do not work with NFS servers that limit lock range to max file size

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 6, 6u5
    • Fix Version/s: 7
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Introduced In Version:
    • Resolved In Build:
      b25
    • CPU:
      generic, x86, sparc
    • OS:
      generic, other, solaris_2.5.1
    • Verification:
      Not verified

      Description

      The customers application does not boot when the
      application tries to lock files hosted on an NFSv3 file system running on HP-UX 11.23 which checks the 'len' argument against the maximum file size and returns error.

      The java.nio.channels.FileChannel.tryLock() implementation translates into the following system call:

      fcntl64(17, F_SETLK64, {type=F_WRLCK, whence=SEEK_SET, start=0,
      len=9223372036854775807}, 0xbfffd0e0)

      where len argument is set to maximum of long type ( 2^63 - 1 ==
      9223372036854775807 ).

      This causes problem when using HP-UX 11.23 NFS server, which checks the 'len' argument against the maximum file size and returns error, which is correspondent with NFSv3 rfc document.

        To lock the whole file the 'len' argument should be set to 0.
      eg. have an OS call translate into the following:

      fcntl64(17, F_SETLK64, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0},0xbfffd0e0)

      which is also documented in fcntl manual page.

      Supposedly this is an incorrect implementation of locking the whole file in the SUN jdk and would like it to be fixed using zero length lock offset size.

      Analysis shows that java.nio.channels.FileChannel.tryLock() is implemented
      as:

          public final FileLock tryLock() throws IOException
          { return tryLock(0L, 0x7fffffffffffffffL, false); }

      The customer would prefer:

          public final FileLock tryLock() throws IOException
          { return tryLock(0L, 0x0L, false);

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alanb Alan Bateman
                Reporter:
                ndcosta Nelson Dcosta (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: