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

(fs) FileChannel.transferFrom does not throw ClosedChannelException

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      hopper
    • CPU:
      sparc
    • OS:
      solaris_2.6
    • Verification:
      Verified

      Description



      Name: auR10023 Date: 03/28/2002


      java.nio.channels.FileChannel.transferFrom(ReadableByteChannel, long,
      long) method does not throw ClosedChannelException with
      closed ReadableByteChannel. Here is the example:

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

      public class test {
          public static void main (String args []) {
              FileChannel channel = null;
              try {
                  channel = (new FileOutputStream("aaa")).getChannel();
              } catch (IOException e) {
                  System.out.println("Unexpected IOException");
              }
              ByteArrayInputStream istr = new ByteArrayInputStream(
                  new byte [] {1, 2, 3, 4}
              );
              ReadableByteChannel rch = Channels.newChannel(istr);
              try {
                  rch.close();
              } catch (IOException e) {
                  System.out.println(e);
              }
              try {
                  channel.transferFrom(rch, 0, 2);
                  System.out.println("ClosedChannelException expected");
              } catch (Throwable e) {
                  System.out.println(e);
              }
          }
          
      #java -version
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

      #java test
      ClosedChannelException expected

      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            mmcclosksunw Michael Mccloskey (Inactive)
            Reporter:
            avusunw Avu Avu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: