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:
Chris M. Hostetter 2008-12-19 06:12:57 +00:00
parent bbe3c679db
commit d495237c0e
1 changed files with 5 additions and 8 deletions

View File

@ -56,10 +56,10 @@ final class RequestHandlers {
new ConcurrentHashMap<String,SolrRequestHandler>() ;
/**
* Trim the trailing '/' if its there.
* Trim the trailing '/' if its there, and convert null to empty string.
*
* we want:
* /update/csv
* /update/csv and
* /update/csv/
* to map to the same handler
*
@ -67,7 +67,7 @@ final class RequestHandlers {
private static String normalize( String p )
{
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;
@ -93,16 +93,13 @@ final class RequestHandlers {
* @return the previous handler at the given path or null
*/
public SolrRequestHandler register( String handlerName, SolrRequestHandler handler ) {
if(handlerName == null) return null;
String norm = normalize( handlerName );
if( handler == null ) {
return handlers.remove( norm );
}
SolrRequestHandler old = handlers.put(norm, handler);
if (handlerName != null && handlerName != "") {
if (handler instanceof SolrInfoMBean) {
core.getInfoRegistry().put(handlerName, handler);
}
if (0 != norm.length() && handler instanceof SolrInfoMBean) {
core.getInfoRegistry().put(handlerName, handler);
}
return old;
}