SOLR-215 -- synchronizing getSolrCore()

see: http://www.nabble.com/synchronization-issue-in-SolrCore.getSolrCore%28%29---tf4477891.html

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@577395 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan McKinley 2007-09-19 17:32:16 +00:00
parent 533f5cb7a5
commit e3adf0ec78
1 changed files with 10 additions and 7 deletions

View File

@ -237,13 +237,16 @@ public final class SolrCore {
*/
@Deprecated
public static SolrCore getSolrCore() {
if( instance == null ) {
try {
instance = new SolrCore(null, new SolrConfig(), null);
}
catch(Exception xany) {
log.throwing("SolrCore", "getSolrCore", xany);
return null;
synchronized( SolrCore.class ) {
if( instance == null ) {
try {
// sets 'instance' to the latest solr core
instance = new SolrCore(null, new SolrConfig(), null);
}
catch(Exception xany) {
log.throwing("SolrCore", "getSolrCore", xany);
return null;
}
}
}
return instance;