From d04b8adc201a5f5ffce6925ff8ea31b472aee03e Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Mon, 27 Jun 2016 09:55:43 +0000 Subject: [PATCH] fixed ckanutils creation git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@129464 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../GcubeCkanDataCatalogServiceImpl.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GcubeCkanDataCatalogServiceImpl.java b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GcubeCkanDataCatalogServiceImpl.java index e62a95f..79952b6 100644 --- a/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GcubeCkanDataCatalogServiceImpl.java +++ b/src/main/java/org/gcube/portlets/gcubeckan/gcubeckandatacatalog/server/GcubeCkanDataCatalogServiceImpl.java @@ -64,6 +64,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem // ckan utils methods private CKanUtilsImpl instance; + private Object LOCK = new Object(); /** * Since it needs the scope, we need to check if it is null or not @@ -72,13 +73,17 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem private CKanUtilsImpl getCkanUtilsObj(){ if(instance == null){ - // retrieve ckan information - try{ - String currentScope = ScopeProvider.instance.get(); - logger.debug("Scope is " + currentScope); - instance = new CKanUtilsImpl(currentScope); - }catch(Exception e){ - logger.error("Unable to retrieve ckan information", e); + synchronized(LOCK){ + if(instance == null){ + // retrieve ckan information + try{ + String currentScope = ScopeProvider.instance.get(); + logger.debug("Scope is " + currentScope); + instance = new CKanUtilsImpl(currentScope); + }catch(Exception e){ + logger.error("Unable to retrieve ckan information", e); + } + } } }