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

java.nio.FileChannel.transferFrom() doesn't increment source channel position

XMLWordPrintable

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

      transferFrom() is expected to increment the position of source channel by number of bytes read. However, the position is unchanged after transferFrom completes successfully.

      ------ test code xferTest02() -----------
      System.out.println("BEFORE:fc1.position=" + fc1.position() + ", fc1.size=" + fc1.size());
      System.out.println("BEFORE:fc2.position=" + fc2.position() + ", fc2.size=" + fc2.size());

      bytesWritten = fc2.transferFrom(fc1, 0, srcData.length);

      System.out.println("AFTER:fc1.position=" + fc1.position() + ", fc1.size=" + fc1.size() + ", bytesWritten=" + bytesWritten);
      System.out.println("AFTER:fc2.position=" + fc2.position() + ", fc2.size=" + fc2.size());

      ------- results ------------------
      BEFORE:fc1.position=0, fc1.size=2683
      BEFORE:fc2.position=0, fc2.size=0
      AFTER:fc1.position=0, fc1.size=2683, bytesWritten=2683
      AFTER:fc2.position=0, fc2.size=2683
      ------------------------
      build 1.4.0-beta-b61
      same results on Solaris, IA, Windows, Linux.

            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: