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

(fs) FileChannel.tryLock throws IOException on Linux

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.4.0_02
    • core-libs
    • None
    • generic
    • linux_redhat_7.2

      The java.nio.channels.FileChannel.tryLock(0L, Long.MAX_VALUE, false) throws
                   IOException on Linux but works on Solaris.
      Seen in JDK 1.4.0_02 (prerelease). Does not happen in 1.4.1 beta

      Attaching a test case: LockTest.java


                   import java.io.*;
                   import java.nio.channels.*;

                   public class LockTest {

                           public static final String LOCK_NAME = "domains.lck";
                           private static File STORE;

                           public static void main( String[] args ) throws FileNotFoundException {
                                   boolean shared = false;
                                   STORE = new File("/space/svbld", LOCK_NAME);
                                   try {
                                           RandomAccessFile raf = new RandomAccessFile(STORE,
                   "rws");
                                           FileChannel channel = raf.getChannel();
                                           FileLock lock = channel.tryLock(0L, Long.MAX_VALUE,
                   shared);
                                   }
                                   catch ( IOException f ) {
                                           System.out.println("IOException caught");
                                   }
                           }
                   }

      (Filing on behalf of Dipankar Roy and Rajesh Navaneetham)

      Wed Jul 24 12:24:11 MDT 2002 tsteele@litehouse

            mr Mark Reinhold
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: