abdullah alamoudi has submitted this change and it was merged. Change subject: Coverity Fix for Bad Lock Object ......................................................................
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 <[email protected]> Reviewed-by: Ian Maxon <[email protected]> Reviewed-by: abdullah alamoudi <[email protected]> --- M asterix-external-data/src/main/java/org/apache/asterix/external/input/HDFSDataSourceFactory.java 1 file changed, 9 insertions(+), 8 deletions(-) Approvals: abdullah alamoudi: Looks good to me, approved Ian Maxon: Looks good to me, but someone else must approve Jenkins: Verified 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 @@ 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 @@ @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 @@ * 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; + } } } } -- To view, visit https://asterix-gerrit.ics.uci.edu/665 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib993d94bfae6b788b5b56d388fa7a33ec958dee4 Gerrit-PatchSet: 2 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Michael Blow <[email protected]> Gerrit-Reviewer: Ian Maxon <[email protected]> Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Till Westmann <[email protected]> Gerrit-Reviewer: Yingyi Bu <[email protected]> Gerrit-Reviewer: abdullah alamoudi <[email protected]>
