You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Tony Wu (JIRA)" <ji...@apache.org> on 2007/07/03 07:02:05 UTC

[jira] Assigned: (HARMONY-4311) [classlib][luni] Compatibility: OutputStream.write(null, off, len) exception throwing order differs on Harmony and RI

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

Tony Wu reassigned HARMONY-4311:
--------------------------------

    Assignee: Tony Wu

> [classlib][luni] Compatibility: OutputStream.write(null, off, len) exception throwing order differs on Harmony and RI
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4311
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4311
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Elena Sayapina
>            Assignee: Tony Wu
>            Priority: Minor
>
> OutputStream.write(null, off, len) exception throwing order differs on Harmony and RI
> This method throw IndexOutOfBoundsException on Harmony if byte array is null and offset is negative, but throw NullPointerException on RI. 
> PipedOutputStream.write(null, off, len) behaves the same way.
> Please, consider the following code: 
> import java.io.IOException;
> import java.io.OutputStream;
> import java.io.PipedInputStream;
> import java.io.PipedOutputStream;
> public class OutputStreamTest {
> 	public static void main(String[] args) {
> 		
> 		byte[] array = null;
> 		
> 		System.out.println("OutputStream: Byte array is null, offset is negative");
> 		try {
> 	    	OutputStream out = new OutputStreamImpl();
> 	    	out.write(array, -10, 10);
> 	    } catch (NullPointerException e) {
> 	    	System.out.println("TEST OK: " + e);
> 	    } catch (Exception e) {
> 	    	System.out.println("TEST: NullPointerException was expected but " +
> 	    			e.getClass().getName() + " was thrown");
> 	    } 
> 	    
> 	    System.out.println("PipedOutputStream: Byte array is null, offset is negative");
> 	    try {
> 	    	PipedInputStream pis = new PipedInputStream();
> 	    	PipedOutputStream out = new PipedOutputStream(pis);
> 	    	out.write(array, -10, 10);
> 	    } catch (NullPointerException e) {
> 	    	System.out.println("TEST OK: " + e);
> 	    } catch (Exception e) {
> 	    	System.out.println("TEST: NullPointerException was expected but " +
> 	    			e.getClass().getName() + " was thrown");
> 	    } 
> 	}
> }
> class OutputStreamImpl extends OutputStream {
>     public final void write(int b) throws IOException {
>     	throw new IOException("unimplemented");
>     }
> }
> Output on Harmony-r551018:
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
> as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r551018, (Jun 27 2007), Windows/ia32/msvc 1310, release build
> http://harmony.apache.org
> OutputStream: Byte array is null, offset is negative
> TEST: NullPointerException was expected but java.lang.IndexOutOfBoundsException was thrown
> PipedOutputStream: Byte array is null, offset is negative
> TEST: NullPointerException was expected but java.lang.IndexOutOfBoundsException was thrown
> Output on RI:
> java version "1.5.0_11"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)
> OutputStream: Byte array is null, offset is negative
> TEST OK: java.lang.NullPointerException
> PipedOutputStream: Byte array is null, offset is negative
> TEST OK: java.lang.NullPointerException
> Please note that if byte array is null and length is negative NullPointerException is thrown on Harmony as on RI

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