From 663f27bd80c8739518b87990f43a6a96f72e3921 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Wed, 17 Dec 2008 22:50:22 +0000 Subject: [PATCH] SOLR-927: remove synchronization from lazy loaded handler lookup git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@727564 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/solr/core/RequestHandlers.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/java/org/apache/solr/core/RequestHandlers.java b/src/java/org/apache/solr/core/RequestHandlers.java index a974b6afe87..9022b6ebef6 100644 --- a/src/java/org/apache/solr/core/RequestHandlers.java +++ b/src/java/org/apache/solr/core/RequestHandlers.java @@ -229,29 +229,34 @@ final class RequestHandlers { * Wait for the first request before initializing the wrapped handler */ public void handleRequest(SolrQueryRequest req, SolrQueryResponse rsp) { - getWrappedHandler().handleRequest( req, rsp ); + SolrRequestHandler handler = _handler; + if (handler == null) { + handler = getWrappedHandler(); + } + handler.handleRequest( req, rsp ); } - public synchronized SolrRequestHandler getWrappedHandler() + public synchronized SolrRequestHandler getWrappedHandler() { if( _handler == null ) { try { - _handler = core.createRequestHandler(_className); - _handler.init( _args ); - - if( _handler instanceof ResourceLoaderAware ) { + SolrRequestHandler handler = core.createRequestHandler(_className); + handler.init( _args ); + + if( handler instanceof ResourceLoaderAware ) { ((ResourceLoaderAware)_handler).inform( core.getSolrConfig().getResourceLoader() ); } - - if( _handler instanceof SolrCoreAware ) { - ((SolrCoreAware)_handler).inform( core ); + + if( handler instanceof SolrCoreAware ) { + ((SolrCoreAware)handler).inform( core ); } + _handler = handler; } catch( Exception ex ) { throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "lazy loading error", ex ); } } - return _handler; + return _handler; } public String getHandlerClass()