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

java.io.ObjectInputStream.available() returns incorrect value

    XMLWordPrintable

    Details

      Description



      Name: ooR10001 Date: 01/17/2001


      java.io.ObjectInputStream.available() returns incorrect value 0 instead actual data length.
      It causes JCK API test failure and needs to be fixed.

      This sample is sowing a bug:
      --------------------------------
      import java.io.*;

      public class t {

        public static void main(String[] args) {
          try {
              byte[] data = {1, 2, 3, 4, 5, 6, 7, 8};
              ByteArrayOutputStream b = new ByteArrayOutputStream();
              ObjectOutputStream oos = new ObjectOutputStream(b);
              oos.write(data);
              oos.close();
              ByteArrayInputStream bais = new ByteArrayInputStream(b.toByteArray());
              ObjectInputStream ois = new ObjectInputStream(bais);
              System.out.println(ois.available());
          } catch (Exception e) {
          }
        }

      }
      --------------------------------

      Output:
      ---------------------------------
      0
      ---------------------------------

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mwarressunw Michael Warres (Inactive)
              Reporter:
              oovsunw Oov Oov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: