You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Vasily Zakharov (JIRA)" <ji...@apache.org> on 2006/12/07 17:54:22 UTC
[jira] Commented: (HARMONY-2525) [classlib][jndi]
javax.naming.CompoundName add(String), add(int, String) methods should
follow exception throwing compatibility
[ http://issues.apache.org/jira/browse/HARMONY-2525?page=comments#action_12456482 ]
Vasily Zakharov commented on HARMONY-2525:
------------------------------------------
Anton,
In fact, null components are not permitted by the Name syntax: "None of the methods in this interface accept null as a valid value for a parameter that is a name or a name component. Likewise, methods that return a name or name component never return null." Also "non-null" is clearly specified in the add() methods' documentation.
In other words, exception must be thrown if null parameter is passed to add() method, though it's not documented explicitly. I agree that InvalidNameException should not be thrown in this case, but probably IllegalArgumentException or NullPointerException should be thrown.
RI is doing no good by accepting null parameters.
Vasily
> [classlib][jndi] 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