You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Regis Xu (JIRA)" <ji...@apache.org> on 2009/05/31 13:00:07 UTC

[jira] Updated: (HARMONY-6216) problem with reading zero-length file

     [ https://issues.apache.org/jira/browse/HARMONY-6216?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Regis Xu updated HARMONY-6216:
------------------------------

    Attachment: HARMONY-6216.diff

Would you please try this patch? It could work for me after applying it.

java.io.InputStreamReader.read(char[], int, int) will invoke java.io.InputStream.available() to try to earlier return before reading from underline stream, but  InputStream.available() is illegal on the special file, so I just remove this speculation.

> problem with reading zero-length file
> -------------------------------------
>
>                 Key: HARMONY-6216
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6216
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M10
>         Environment: RedHat EL 5 x86
>            Reporter: Kyle Cho
>            Priority: Minor
>         Attachments: HARMONY-6216.diff
>
>
> 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

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.