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>() ;
|
||||
|
||||
/**
|
||||
* 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,17 +93,14 @@ 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) {
|
||||
if (0 != norm.length() && handler instanceof SolrInfoMBean) {
|
||||
core.getInfoRegistry().put(handlerName, handler);
|
||||
}
|
||||
}
|
||||
return old;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue