diff --git a/solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.java index 82664b23623..cadb5a735c5 100644 --- a/solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.java +++ b/solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.java @@ -91,44 +91,40 @@ public static SolrCore getCore( String syntheticCollectionName = getSyntheticCollectionName(confName); DocCollection syntheticColl = clusterState.getCollectionOrNull(syntheticCollectionName); - synchronized (CoordinatorHttpSolrCall.class) { - if (syntheticColl == null) { - // no synthetic collection for this config, let's create one - if (log.isInfoEnabled()) { - log.info( - "synthetic collection: {} does not exist, creating.. ", syntheticCollectionName); - } + if (syntheticColl == null) { + // no synthetic collection for this config, let's create one + if (log.isInfoEnabled()) { + log.info( + "synthetic collection: {} does not exist, creating.. ", syntheticCollectionName); + } - SolrException createException = null; - try { - createColl(syntheticCollectionName, solrCall.cores, confName); - } catch (SolrException exception) { - // concurrent requests could have created the collection hence causing collection - // exists - // exception - createException = exception; - } finally { - syntheticColl = - zkStateReader.getClusterState().getCollectionOrNull(syntheticCollectionName); - } + SolrException createException = null; + try { + createColl(syntheticCollectionName, solrCall.cores, confName); + } catch (SolrException exception) { + // concurrent requests could have created the collection hence causing collection exists + // exception + createException = exception; + } finally { + syntheticColl = + zkStateReader.getClusterState().getCollectionOrNull(syntheticCollectionName); + } - // then indeed the collection was not created properly, either by this or other - // concurrent - // requests - if (syntheticColl == null) { - if (createException != null) { - throw createException; // rethrow the exception since such collection was not - // created - } else { - throw new SolrException( - SolrException.ErrorCode.SERVER_ERROR, - "Could not locate synthetic collection [" - + syntheticCollectionName - + "] after creation!"); - } + // then indeed the collection was not created properly, either by this or other concurrent + // requests + if (syntheticColl == null) { + if (createException != null) { + throw createException; // rethrow the exception since such collection was not created + } else { + throw new SolrException( + SolrException.ErrorCode.SERVER_ERROR, + "Could not locate synthetic collection [" + + syntheticCollectionName + + "] after creation!"); } } - + } + synchronized (CoordinatorHttpSolrCall.class) { // get docCollection again to ensure we get the fresh state syntheticColl = zkStateReader.getClusterState().getCollectionOrNull(syntheticCollectionName);