From d495237c0e7b3405e107cca1348b5d91b6588ae1 Mon Sep 17 00:00:00 2001 From: "Chris M. Hostetter" Date: Fri, 19 Dec 2008 06:12:57 +0000 Subject: [PATCH] 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 --- src/java/org/apache/solr/core/RequestHandlers.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) 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() ; /** - * 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; }