cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r822459 - /incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
Date Tue, 06 Oct 2009 19:41:57 GMT
Author: jbellis
Date: Tue Oct  6 19:41:57 2009
New Revision: 822459

URL: http://svn.apache.org/viewvc?rev=822459&view=rev
Log:
replace one-shot lock w/ synchronized block.  patch by jbellis

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java?rev=822459&r1=822458&r2=822459&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java Tue
Oct  6 19:41:57 2009
@@ -79,8 +79,6 @@
     public final static String rangeVerbHandler_ = "RANGE-VERB-HANDLER";
 
     private static StorageService instance_;
-    /* Used to lock the factory for creation of StorageService instance */
-    private static Lock createLock_ = new ReentrantLock();
     private static EndPoint tcpAddr_;
     private static EndPoint udpAddr_;
     private static IPartitioner partitioner_;
@@ -126,29 +124,24 @@
     {
         String bs = System.getProperty("bootstrap");
         boolean bootstrap = bs != null && bs.contains("true");
-        
-        if ( instance_ == null )
+
+        if (instance_ == null)
         {
-            StorageService.createLock_.lock();
-            try
+            synchronized (StorageService.class)
             {
-                if ( instance_ == null )
+                if (instance_ == null)
                 {
                     try
                     {
                         instance_ = new StorageService(bootstrap);
                     }
-                    catch ( Throwable th )
+                    catch (Throwable th)
                     {
                         logger_.error(LogUtil.throwableToString(th));
                         System.exit(1);
                     }
                 }
             }
-            finally
-            {
-                createLock_.unlock();
-            }
         }
         return instance_;
     }



Mime
View raw message