harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r892226 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java
Date Fri, 18 Dec 2009 11:39:47 GMT
Author: tellison
Date: Fri Dec 18 11:39:47 2009
New Revision: 892226

URL: http://svn.apache.org/viewvc?rev=892226&view=rev
Log:
Fix for HARMONY-6405 ([classlib][luni] String.equals() is not thread-safe)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java?rev=892226&r1=892225&r2=892226&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java Fri Dec
18 11:39:47 2009
@@ -778,8 +778,9 @@
         }
         if (object instanceof String) {
             String s = (String) object;
-            if (count != s.count
-                    || (hashCode != s.hashCode && hashCode != 0 && s.hashCode
!= 0)) {
+            int hash = hashCode;  // Single read on hashCodes as they may change
+            int shash = s.hashCode;
+            if (count != s.count || (hash != shash && hash != 0 && shash
!= 0)) {
                 return false;
             }
             for (int i = 0; i < count; ++i) {



Mime
View raw message