mirror of https://github.com/apache/lucene.git
SOLR-917 followup. improve handling of null handler name to make semantics closer to what they were before ConcurrentHashMap, and cleanup some now superfulous null checks
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@727934 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bbe3c679db
commit
d495237c0e
|
@ -56,10 +56,10 @@ final class RequestHandlers {
|
||||||
new ConcurrentHashMap<String,SolrRequestHandler>() ;
|
new ConcurrentHashMap<String,SolrRequestHandler>() ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trim the trailing '/' if its there.
|
* Trim the trailing '/' if its there, and convert null to empty string.
|
||||||
*
|
*
|
||||||
* we want:
|
* we want:
|
||||||
* /update/csv
|
* /update/csv and
|
||||||
* /update/csv/
|
* /update/csv/
|
||||||
* to map to the same handler
|
* to map to the same handler
|
||||||
*
|
*
|
||||||
|
@ -67,7 +67,7 @@ final class RequestHandlers {
|
||||||
private static String normalize( String p )
|
private static String normalize( String p )
|
||||||
{
|
{
|
||||||
if(p == null) return "";
|
if(p == null) return "";
|
||||||
if( p != null && p.endsWith( "/" ) && p.length() > 1 )
|
if( p.endsWith( "/" ) && p.length() > 1 )
|
||||||
return p.substring( 0, p.length()-1 );
|
return p.substring( 0, p.length()-1 );
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
|
@ -93,16 +93,13 @@ final class RequestHandlers {
|
||||||
* @return the previous handler at the given path or null
|
* @return the previous handler at the given path or null
|
||||||
*/
|
*/
|
||||||
public SolrRequestHandler register( String handlerName, SolrRequestHandler handler ) {
|
public SolrRequestHandler register( String handlerName, SolrRequestHandler handler ) {
|
||||||
if(handlerName == null) return null;
|
|
||||||
String norm = normalize( handlerName );
|
String norm = normalize( handlerName );
|
||||||
if( handler == null ) {
|
if( handler == null ) {
|
||||||
return handlers.remove( norm );
|
return handlers.remove( norm );
|
||||||
}
|
}
|
||||||
SolrRequestHandler old = handlers.put(norm, handler);
|
SolrRequestHandler old = handlers.put(norm, handler);
|
||||||
if (handlerName != null && handlerName != "") {
|
if (0 != norm.length() && handler instanceof SolrInfoMBean) {
|
||||||
if (handler instanceof SolrInfoMBean) {
|
core.getInfoRegistry().put(handlerName, handler);
|
||||||
core.getInfoRegistry().put(handlerName, handler);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue