Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-6216

problem with reading zero-length file

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 5.0M10
    • 5.0M12
    • Classlib
    • None
    • RedHat EL 5 x86
    • Unknown

    Description

      The following test fails:

      ----------------------- proc.java starts ------------------
      import java.io.*;
      class proc {
      public static void main(String args[])
      {
      String s0 = "cpu";
      String s = null;
      String file= "/proc/cpuinfo"; // zero-length special file
      try {
      BufferedReader br = new BufferedReader(new FileReader(new File(file)));
      do {
      if ((s = br.readLine()) == null)

      { break; }

      System.out.println("s: "+s);
      } while (s.indexOf(s0) == -1);
      } catch (IOException ioe)

      { ioe.printStackTrace(); }

      System.out.println("s: "+s);
      }
      }
      ----------------------- proc.java ends -------------------

      java.io.IOException
      at org.apache.harmony.luni.platform.OSFileSystem.seek(OSFileSystem.java:110)
      at java.io.FileInputStream.available(FileInputStream.java:149)
      at java.io.InputStreamReader.read(InputStreamReader.java:249)
      at java.io.BufferedReader.fillbuf(BufferedReader.java:107)
      at java.io.BufferedReader.readLine(BufferedReader.java:318)
      at proc.main(proc.java:11)
      s: null

      Attachments

        1. HARMONY-6216.diff
          0.8 kB
          Regis Xu
        2. HARMONY-6216.simple.diff
          1 kB
          Mark Hindess

        Activity

          People

            hindessm Mark Hindess
            kylecho Kyle Cho
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: