harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r427572 - in /incubator/harmony/enhanced/classlib/trunk/modules/jndi/src: main/java/javax/naming/CompoundName.java test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java
Date Tue, 01 Aug 2006 13:21:07 GMT
Author: mloenko
Date: Tue Aug  1 06:21:06 2006
New Revision: 427572

URL: http://svn.apache.org/viewvc?rev=427572&view=rev
Log:
applied patch for HARMONY-1021
[classlib][jndi] unexpected ArrayIndexOutOfBoundsException for CompoundName.add(int, null)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java
    incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java?rev=427572&r1=427571&r2=427572&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java
Tue Aug  1 06:21:06 2006
@@ -661,6 +661,9 @@
     }
 
     public Name add(String element) throws InvalidNameException {
+        if (element == null) {
+            throw new InvalidNameException("A flat name can only have a single component");
+        }
         elem.add(element);
         return this;
     }
@@ -678,6 +681,9 @@
      * 						this <code>CompoundName</code> becoming invalid.
      */
     public Name add(int index, String element) throws InvalidNameException {
+        if (element == null) {
+            throw new InvalidNameException("A flat name can only zero or one component");
+        }
         validateIndex(index, true);
         elem.add(index, element);
         return this;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java?rev=427572&r1=427571&r2=427572&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java
Tue Aug  1 06:21:06 2006
@@ -1114,7 +1114,12 @@
 		CompoundName name;
 
 		name = new CompoundName("", props);
-		name.add(null);
+		try {
+			name.add(null);
+			fail("InvalidNameException expected");
+		} catch (InvalidNameException e) {
+			//expected
+		}
 	}
 
 	public void testAdd_Indexed() throws InvalidNameException {
@@ -1146,7 +1151,21 @@
 		CompoundName name;
 
 		name = new CompoundName("", props);
-		name.add(0, null);
+		try {
+			name.add(0, null);
+			fail("InvalidNameException expected");
+		} catch (InvalidNameException e) {
+			//expected
+		}
+
+		// regression test for HARMONY-1021
+		name = new CompoundName("", props);
+		try {
+			name.add(11, null);
+			fail("InvalidNameException expected");
+		} catch (InvalidNameException e) {
+			//expected
+		}
 	}
 
 	public void testRemove() throws InvalidNameException {



Mime
View raw message