Author: hossman
Date: Thu Dec 18 22:12:57 2008
New Revision: 727934
URL: http://svn.apache.org/viewvc?rev=727934&view=rev
Log:
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
Modified:
lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java
Modified: lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java?rev=727934&r1=727933&r2=727934&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java
(original)
+++ lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java Thu
Dec 18 22:12:57 2008
@@ -56,10 +56,10 @@
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 @@
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 @@
* @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;
}