harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Ivanov (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-2525) javax.naming.CompoundName add(String), add(int, String) methods should follow exception throwing compatibility
Date Thu, 07 Dec 2006 16:23:21 GMT
javax.naming.CompoundName add(String), add(int, String) methods should follow exception throwing
compatibility
--------------------------------------------------------------------------------------------------------------

                 Key: HARMONY-2525
                 URL: http://issues.apache.org/jira/browse/HARMONY-2525
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Anton Ivanov
            Priority: Trivial


The behaviour of add(String), add(int, String) methods where String parameter is null is not
explicitly specified.
It is only said in the specification that String parameter have to be non-null.

1) add(null)
RI: no exceptions are thrown
Harmony: InvalidNameException is thrown

2) add(int, null)
RI: no exceptions are thrown or IndexOutOfBoundsException is thrown
Harmony: InvalidNameException is thrown

The following test reproduces the problem:

import junit.framework.TestCase;
import java.util.*;
import javax.naming.*;

public class ExceptionCompatibilityTest extends TestCase {

    public void test1() {
        try {
            CompoundName name = new CompoundName("", new Properties());
            name.add(null);
        } catch (InvalidNameException e) {
            fail(e + " should not be thrown");
        }
    }

    public void test2() {
        try {
            CompoundName name = new CompoundName("", new Properties());    
            name.add(0, null);
        } catch (InvalidNameException e) {
            fail(e + "should not be thrown");
        }
    }
    
    public void test3() {
        try {
            CompoundName name = new CompoundName("", new Properties());    
            name.add(10, null);
        } catch (InvalidNameException e) {
            fail("ArrayIndexOutOfBoundsException should be thrown");
        } catch (ArrayIndexOutOfBoundsException e) {
            //passed
        }
    }
}

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