harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r999623 - /harmony/enhanced/java/trunk/classlib/modules/rmi/src/main/java/java/rmi/server/ObjID.java
Date Tue, 21 Sep 2010 20:39:37 GMT
Author: tellison
Date: Tue Sep 21 20:39:37 2010
New Revision: 999623

URL: http://svn.apache.org/viewvc?rev=999623&view=rev
Log:
Apply fix for HARMONY-6653 (Use instance lock to protect static share data in ObjID.jav)

Modified:
    harmony/enhanced/java/trunk/classlib/modules/rmi/src/main/java/java/rmi/server/ObjID.java

Modified: harmony/enhanced/java/trunk/classlib/modules/rmi/src/main/java/java/rmi/server/ObjID.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/rmi/src/main/java/java/rmi/server/ObjID.java?rev=999623&r1=999622&r2=999623&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/rmi/src/main/java/java/rmi/server/ObjID.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/rmi/src/main/java/java/rmi/server/ObjID.java
Tue Sep 21 20:39:37 2010
@@ -133,6 +133,11 @@ public final class ObjID implements Seri
     private static class NumberGenerator {
         // Counter to be used in case of insecure mode.
         static long numCounter = 65536; // 2^16
+        
+        private static class RMINumberGeneratorLock {
+            // Used to identify local lock.
+        }
+        private static final Object monitor = new RMINumberGeneratorLock();
 
         // Secure generator.
         SecureRandom sGenerator;
@@ -149,8 +154,10 @@ public final class ObjID implements Seri
         /*
          * Returns next long number.
          */
-        synchronized long nextLong() {
-            return useRandom ? sGenerator.nextLong() : numCounter++;
+        long nextLong() {
+            synchronized (monitor) {
+                return useRandom ? sGenerator.nextLong() : numCounter++;
+            }
         }
     }
 }



Mime
View raw message