harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Elena Sayapina (JIRA)" <j...@apache.org>
Subject [jira] Closed: (HARMONY-4311) [classlib][luni] Compatibility: OutputStream.write(null, off, len) exception throwing order differs on Harmony and RI
Date Wed, 04 Jul 2007 11:50:04 GMT

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

Elena Sayapina closed HARMONY-4311.
-----------------------------------


Thank you, Tony.
Verified using Harmony-r553113-msvc-release.

> [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.


Mime
View raw message