harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Hindess (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-6216) problem with reading zero-length file
Date Wed, 04 Nov 2009 08:17:32 GMT

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

Mark Hindess updated HARMONY-6216:
----------------------------------

    Attachment: HARMONY-6216.simple.diff

Why not do something like my patch?  That is, just ignore the IOException from the available
call.  The worse case is that the exception was real but then the read will throw a similar
exception anyway.  As a bonus the exception thrown by the read would make more sense to the
user (since they are trying to read data) than the exception from the available call.

This fixes my immediate problem but I've not run the other tests yet.


> 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
>            Assignee: Regis Xu
>            Priority: Minor
>         Attachments: HARMONY-6216.diff, HARMONY-6216.simple.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.


Mime
View raw message