Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

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

Chris M. Hostetterd495237c0e7b
diff --git a/src/java/org/apache/solr/core/RequestHandlers.java b/src/java/org/apache/solr/core/RequestHandlers.java
index 9022b6ebef6..f81dddc75aa 100644
--- a/src/java/org/apache/solr/core/RequestHandlers.java
+++ b/src/java/org/apache/solr/core/RequestHandlers.java
@@ -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;
}