You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by am...@apache.org on 2016/02/25 07:40:02 UTC

incubator-asterixdb git commit: Coverity Fix for Bad Lock Object

Repository: incubator-asterixdb
Updated Branches:
  refs/heads/master 07536835d -> e2fd984eb


Coverity Fix for Bad Lock Object

CID 68477: Bad choice of lock object (BAD_LOCK_OBJECT)
- boxed_lock:
Boxing a primitive may or may not return a canonical boxed
representation depending upon the value of the primitive being boxed.
Thus, using a boxed primitive as a lock is dangerous.

Change-Id: Ib993d94bfae6b788b5b56d388fa7a33ec958dee4
Reviewed-on: https://asterix-gerrit.ics.uci.edu/665
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Ian Maxon <im...@apache.org>
Reviewed-by: abdullah alamoudi <ba...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/commit/e2fd984e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/tree/e2fd984e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/diff/e2fd984e

Branch: refs/heads/master
Commit: e2fd984eb8bd0636de2cd59661f2ff6a6b3cf6bc
Parents: 0753683
Author: Michael Blow <mi...@couchbase.com>
Authored: Wed Feb 24 19:46:48 2016 -0500
Committer: abdullah alamoudi <ba...@gmail.com>
Committed: Wed Feb 24 22:34:26 2016 -0800

----------------------------------------------------------------------
 .../external/input/HDFSDataSourceFactory.java      | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/e2fd984e/asterix-external-data/src/main/java/org/apache/asterix/external/input/HDFSDataSourceFactory.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/input/HDFSDataSourceFactory.java b/asterix-external-data/src/main/java/org/apache/asterix/external/input/HDFSDataSourceFactory.java
index aa35383..5b3828d 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/input/HDFSDataSourceFactory.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/input/HDFSDataSourceFactory.java
@@ -60,6 +60,7 @@ public class HDFSDataSourceFactory
     protected static Scheduler hdfsScheduler;
     protected static IndexingScheduler indexingScheduler;
     protected static Boolean initialized = false;
+    protected static final Object initLock = new Object();
     protected List<ExternalFile> files;
     protected Map<String, String> configuration;
     protected Class<?> recordClass;
@@ -70,9 +71,7 @@ public class HDFSDataSourceFactory
 
     @Override
     public void configure(Map<String, String> configuration) throws Exception {
-        if (!HDFSDataSourceFactory.initialized) {
-            HDFSDataSourceFactory.initialize();
-        }
+        initialize();
         this.configuration = configuration;
         JobConf conf = HDFSUtils.configureHDFSJobConf(configuration);
         confFactory = new ConfFactory(conf);
@@ -146,11 +145,13 @@ public class HDFSDataSourceFactory
      * HDFS
      */
     private static void initialize() {
-        synchronized (initialized) {
-            if (!initialized) {
-                hdfsScheduler = HDFSUtils.initializeHDFSScheduler();
-                indexingScheduler = HDFSUtils.initializeIndexingHDFSScheduler();
-                initialized = true;
+        if (!initialized) {
+            synchronized (initLock) {
+                if (!initialized) {
+                    hdfsScheduler = HDFSUtils.initializeHDFSScheduler();
+                    indexingScheduler = HDFSUtils.initializeIndexingHDFSScheduler();
+                    initialized = true;
+                }
             }
         }
     }