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

java.nio.FileChannel.write() fails when preceded by force() operation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.4.0
    • 1.4.0
    • core-libs
    • beta
    • sparc
    • solaris_7
    • Verified

      Fails on Window NT / Windows ME. Works on Solaris and Linux.
      Merlin Beta build B-58.

      ------- part of test code -------------
      byte[] dstData ;
      FileChannel fc ;
      String fileName = "test.data" ;
      File file ;
      byte[] srcData = Helper.getRandomByteArray(MIN_DATA_SIZE, MAX_DATA_SIZE);

      try {
                 file = new File(fileName);
                  // get filechannel for the file.
                  fc = Helper.openWriteFileChannel(file) ;
                  fc.write(ByteBuffer.wrap(srcData));
                  fc.force(false);
                  fc.write(ByteBuffer.wrap(srcData)); // << throws IOException
               } catch (IOException e) {
                  return TestHelper.testFail(testName + " FAIL: Unexpected Exception",
       e);

              }


      --------- results -------------------
      H:\test\FCforce>java FCforce
      forceTest01 FAIL: Unexpected Exception
      java.io.IOException: The handle is invalid
              at sun.nio.ch.FileDispatcher.write0(Native Method)
              at sun.nio.ch.FileDispatcher.write(FileDispatcher.java:47)
              at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:60)
              at sun.nio.ch.IOUtil.write(IOUtil.java:42)
              at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:99)
              at FCforce.forceTest01(FCforce.java:142)
      :
      :
      ----------------------------------------

            mmcclosksunw Michael Mccloskey (Inactive)
            hvilekar Harshad Vilekar (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: