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

(fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]

XMLWordPrintable

    • b25
    • 7
    • b123
    • x86
    • windows_xp
    • Verified

      FULL PRODUCT VERSION :
      java version "1.7.0-ea"
      Java(TM) SE Runtime Environment (build 1.7.0-ea-b27)
      Java HotSpot(TM) Client VM (build 13.0-b01, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Verze 5.1.2600]
      (C) Copyright 1985-2001 Microsoft Corp.

      A DESCRIPTION OF THE PROBLEM :
      Tried to run Eclipse 3.1.2-based app with JRE 7. That failed when it tried to lock a file. I tracked the problem down and reproduced it with attached test code. If I use RandomAccessFile instead of FileOutputStream (inspired by the change done in Eclipse 3.3.2) it works.

      Disk volume where the lock file is created is normal filesystem, not networked one.

      Works with JRE 1.5 and 6.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run provided example.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No error.
      ACTUAL -
      Exception.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.io.IOException: Pstup byl odepen
      at sun.nio.ch.FileChannelImpl.lock0(Native Method)
      at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:903)
      at java.nio.channels.FileChannel.tryLock(FileChannel.java:978)
      at test.Test.main(Test.java:10)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package test;

      import java.io.File;
      import java.io.FileOutputStream;

      public class Test {
         public static void main(String[] args) throws Exception {
              File lockFile = new File("C:\\temp\\lock");
              FileOutputStream fileStream = new FileOutputStream(lockFile, true);
              fileStream.getChannel().tryLock();
              fileStream.close();
          }
      }

      ---------- END SOURCE ----------

      Release Regression From : 6
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: