harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r448429 - 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 Thu, 21 Sep 2006 01:55:48 GMT
Author: ndbeyer
Date: Wed Sep 20 18:55:47 2006
New Revision: 448429

URL: http://svn.apache.org/viewvc?view=rev&rev=448429
Log:
Apply modified patch for HARMONY-1263:  [classlib][naming] RI CompoundName doesn't clone Properties
passed as a parameter into constructor

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?view=diff&rev=448429&r1=448428&r2=448429
==============================================================================
--- 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
Wed Sep 20 18:55:47 2006
@@ -370,7 +370,7 @@
     private void init(Properties props) {
         trimBlanks = false;
         ignoreCase = false;
-        this.mySyntax = (Properties) props.clone();
+        this.mySyntax = props;
         String property;
 
         //read property settings
@@ -708,15 +708,7 @@
     }
 
     public Object clone() {
-        CompoundName newName = null;
-        try {
-            newName = (CompoundName) super.clone();
-        } catch (CloneNotSupportedException e) {
-            throw new Error("Failed to clone object of CompoundName class"); //$NON-NLS-1$
-        }
-        newName.mySyntax = (Properties) mySyntax.clone();
-        newName.elem = (Vector<String>) elem.clone();
-        return newName;
+        return new CompoundName(getAll(), mySyntax);
     }
 
     public int size() {

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?view=diff&rev=448429&r1=448428&r2=448429
==============================================================================
--- 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
Wed Sep 20 18:55:47 2006
@@ -28,6 +28,7 @@
 
 import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
+
 import org.apache.harmony.jndi.tests.javax.naming.util.Log;
 
 public class CompoundNameTest extends TestCase {
@@ -681,6 +682,15 @@
 		testBehavior("'a<b>c'", props);
 	}
 
+	public void testConstructor_WithIrregularProps() throws InvalidNameException {
+		log.setMethod("testConstructor_WithIrregularProps()");
+		try{
+		    new CompoundName("name", new UncloneableProperties());
+		}catch(UnsupportedOperationException e){
+		    fail("unexpected UnsupportedOperationException");
+		}
+	}
+
 	public void testConstructor_Advanced() throws InvalidNameException {
 		log.setMethod("testConstructor_Advanced()");
 
@@ -1211,6 +1221,24 @@
 		assertNameEquals(name2, "b");
 	}
 
+	public void testClone_1() throws InvalidNameException {
+		log.setMethod("testClone_1()");
+		CompoundName name = null, name2 = null;
+
+		try{
+		    name = new CompoundName("name", new UncloneableProperties());
+		}catch(UnsupportedOperationException e){
+		    fail("unexpected UnsupportedOperationException");
+		}
+
+		try{
+		    name2 = (CompoundName)name.clone();
+		}catch(UnsupportedOperationException e){
+		    fail("unexpected UnsupportedOperationException");
+		}
+		assertEquals(name, name2);
+	}
+
 	public void testCompareTo() throws InvalidNameException {
 		log.setMethod("testCompareTo()");
 
@@ -1730,4 +1758,13 @@
 		name = new CompoundName("||", synt);
 		assertEquals("||", name.toString());
 	}
+    
+    private static class UncloneableProperties extends Properties {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public Object clone() {
+            throw new UnsupportedOperationException();
+        }
+    }
 }



Mime
View raw message