harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r410450 - in /incubator/harmony/enhanced/classlib/trunk/modules/sql/src: main/java/java/sql/Timestamp.java test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java
Date Wed, 31 May 2006 07:46:37 GMT
Author: smishura
Date: Wed May 31 00:46:37 2006
New Revision: 410450

URL: http://svn.apache.org/viewvc?rev=410450&view=rev
Log:
Bug fix for HARMONY-526 ([classlib] unspecified NPE for java.sql.Timestamp.equals(Object)
and equals(Timestamp) methods if parameter == null)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java
  (contents, props changed)
    incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java?rev=410450&r1=410449&r2=410450&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java
Wed May 31 00:46:37 2006
@@ -1,16 +1,16 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 
@@ -156,14 +156,11 @@
 	 * false if the object is not a Timestamp object or if the object is a Timestamp but
 	 * represents a different instant in time
 	 */
-    public boolean equals( Object theObject ) {
-    	Timestamp theTimestamp;
-    	try {
-    		theTimestamp = (Timestamp) theObject;
-    	} catch (ClassCastException e) {
-    		return false;
-    	} // end 
-    	return this.equals( (Timestamp) theTimestamp );
+    public boolean equals(Object theObject) {
+        if (theObject instanceof Timestamp) {
+            return equals((Timestamp) theObject);
+        }
+        return false;
     } // end method equals( Object )
     
 	/**
@@ -172,6 +169,9 @@
 	 * @return true if this Timestamp object is equal to the supplied Timestamp object
 	 */
     public boolean equals( Timestamp theTimestamp ) {
+        if (theTimestamp == null) {
+            return false;
+        }
     	if( (this.getTime() == theTimestamp.getTime()) && (this.getNanos() == theTimestamp.getNanos())
) {
     		return true;
     	} else {

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java?rev=410450&r1=410449&r2=410450&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java
Wed May 31 00:46:37 2006
@@ -454,6 +454,9 @@
 
 			assertFalse(theTimestamp.equals(theTest));
 		} // end for
+        
+        // Regression for HARMONY-526
+        assertFalse(new Timestamp(0).equals((Timestamp) null));
 	} // end method testequalsTimestamp
 
 	/*
@@ -480,6 +483,8 @@
 		Timestamp theTimestamp = new Timestamp(TIME_ARRAY[1]);
 		assertFalse(theTimestamp.equals(nastyTest));
 
+        // Regression for HARMONY-526
+        assertFalse(new Timestamp(0).equals((Object) null));
 	} // end method testequalsObject
 
 	/*



Mime
View raw message