Author: ryan
Date: Thu Jun 5 09:02:35 2008
New Revision: 663645
URL: http://svn.apache.org/viewvc?rev=663645&view=rev
Log:
adding an error message if you create a CommonsHttpSolrServer with parameters
in the baseURL
Modified:
lucene/solr/trunk/client/java/solrj/src/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java
lucene/solr/trunk/client/java/solrj/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java
Modified:
lucene/solr/trunk/client/java/solrj/src/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/client/java/solrj/src/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java?rev=663645&r1=663644&r2=663645&view=diff
==============================================================================
---
lucene/solr/trunk/client/java/solrj/src/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java
(original)
+++
lucene/solr/trunk/client/java/solrj/src/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java
Thu Jun 5 09:02:35 2008
@@ -109,11 +109,14 @@
public CommonsHttpSolrServer(URL baseURL, HttpClient client, ResponseParser
parser) {
- this._baseURL = baseURL.toExternalForm();
- if( this._baseURL.endsWith( "/" ) ) {
- this._baseURL = this._baseURL.substring( 0, this._baseURL.length()-1 );
+ _baseURL = baseURL.toExternalForm();
+ if( _baseURL.endsWith( "/" ) ) {
+ _baseURL = _baseURL.substring( 0, _baseURL.length()-1 );
}
-
+ if( _baseURL.indexOf( '?' ) >=0 ) {
+ throw new RuntimeException( "Invalid base url for solrj. The base URL
must not contain parameters: "+_baseURL );
+ }
+
_httpClient = (client == null) ? new HttpClient(new
MultiThreadedHttpConnectionManager()) : client;
if (client == null) {
Modified:
lucene/solr/trunk/client/java/solrj/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/client/java/solrj/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java?rev=663645&r1=663644&r2=663645&view=diff
==============================================================================
---
lucene/solr/trunk/client/java/solrj/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java
(original)
+++
lucene/solr/trunk/client/java/solrj/test/org/apache/solr/client/solrj/embedded/SolrExampleJettyTest.java
Thu Jun 5 09:02:35 2008
@@ -22,6 +22,7 @@
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.core.SolrCore;
import org.apache.solr.schema.SchemaField;
+import org.junit.Assert;
/**
* TODO? perhaps use:
@@ -79,4 +80,17 @@
throw new RuntimeException( ex );
}
}
+
+ public void testBadSetup()
+ {
+ try {
+ // setup the server...
+ String url = "http://localhost/?core=xxx";
+ CommonsHttpSolrServer s = new CommonsHttpSolrServer( url );
+ Assert.fail( "CommonsHttpSolrServer should not allow a path with a
parameter: "+s.getBaseURL() );
+ }
+ catch( Exception ex ) {
+ // expected
+ }
+ }
}