harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Markov (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-2404) [classlib][luni] java.io.PipedWriter.write(buf,off,len) throws exeptions in different order than RI
Date Fri, 29 Dec 2006 18:55:23 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-2404?page=comments#action_12461429 ] 
            
Mikhail Markov commented on HARMONY-2404:
-----------------------------------------

Tony, I don't think RI sacrifice performance for this type of checking - perhaps they just
need to check a couple of internal variables for null :-).

Throwing IOException first makes sens to me as someone in his/her application could just call
try {
    PipedWriter pw = ...;
    pw.write(...);
catch (IOException ioe) {
    // handle ioe here
    ...
}
If this application run on RI - IOException will be properly handled, on Harmony it'll be
rethrown to the higher level in the stack without catching and could possibly broke the application.
On the other hand, if application is going to write null char array - it should be clearly
some problems there, but who knows :-)

Getting all this into account, i tend for +1 for fixing this issue.



> [classlib][luni] java.io.PipedWriter.write(buf,off,len) throws exeptions in different
order than RI
> ---------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2404
>                 URL: http://issues.apache.org/jira/browse/HARMONY-2404
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Artem Aliev
>            Priority: Minor
>
> java.io.PipedWriter.write(buf,off,len) throws exeptions in different order than
> RI. 
> Harmony at first checks boundary condition while RI checks pipe connection.
> Compatibility issue.
> Test for reproducing:
> import junit.framework.TestCase;
> import java.io.*;
> public class test extends TestCase {      
>     public void test1 () { 
>         try {            
>            PipedWriter obj=new PipedWriter();
>            obj.write(new char[]{1,1},10,1);
>            fail("IOException should be thrown");  
>         } catch (IOException e) {
>             //expected
>         }
>     } 
> }
> Output on Sun 1.5:
> ==================
> .
> Time: 0
> OK (1 test)
> Output on Harmony:
> ==================
> .E
> Time: 0.015
> There was 1 error:
> 1) test1(test)java.lang.IndexOutOfBoundsException
>         at java.io.PipedWriter.write(PipedWriter.java:166)
>         at test.test1(test.java:8)
>         at java.lang.reflect.VMReflection.invokeMethod(Native Method)
> FAILURES!!!
> Tests run: 1,  Failures: 0,  Errors: 1
> The same issue if first parameter buffer==null.
> Harmony throws NullPointerException while RI at first checks pipe connection
> and throws java.io.IOException: Pipe Not Connected.
> import junit.framework.TestCase;
> import java.io.*;
> public class test extends TestCase {      
>     public void test2 () { 
>         try {            
>            PipedWriter obj=new PipedWriter();
>            obj.write((char[])null,10,1);
>            fail("IOException should be thrown");  
>         } catch (IOException e) {
>             //expected
>         }
>     }     
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message