You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by el...@apache.org on 2015/05/13 01:24:26 UTC

svn commit: r1679122 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/CHANGES.txt solr/core/ solr/core/src/test/org/apache/solr/schema/TestCloudSchemaless.java solr/solrj/ solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java

Author: elyograg
Date: Tue May 12 23:24:25 2015
New Revision: 1679122

URL: http://svn.apache.org/r1679122
Log:
SOLR-7243: Return more informative error from CloudSolrServer when available. (merge trunk r1679099)

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/solr/   (props changed)
    lucene/dev/branches/branch_5x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_5x/solr/core/   (props changed)
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/schema/TestCloudSchemaless.java
    lucene/dev/branches/branch_5x/solr/solrj/   (props changed)
    lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java

Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1679122&r1=1679121&r2=1679122&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Tue May 12 23:24:25 2015
@@ -291,6 +291,11 @@ Other Changes
 * SOLR-7500: Remove pathPrefix from SolrDispatchFilter as Solr no longer runs as a part
   of a bigger webapp. (Anshum Gupta)
 
+* SOLR-7243: CloudSolrClient was always returning SERVER_ERROR for exceptions,
+  even when a more relevant ErrorCode was available, via SolrException.  Now
+  the actual ErrorCode is used when available.
+  (Hrishikesh Gadre via Shawn Heisey)
+
 ==================  5.1.0 ==================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/schema/TestCloudSchemaless.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/schema/TestCloudSchemaless.java?rev=1679122&r1=1679121&r2=1679122&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/schema/TestCloudSchemaless.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/schema/TestCloudSchemaless.java Tue May 12 23:24:25 2015
@@ -18,6 +18,7 @@ package org.apache.solr.schema;
 
 import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
 import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
 import org.apache.solr.client.solrj.impl.HttpSolrClient;
 import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
 import org.apache.solr.common.SolrException;
@@ -187,6 +188,15 @@ public class TestCloudSchemaless extends
       } catch (SolrException se) {
         assertEquals(ErrorCode.BAD_REQUEST, ErrorCode.getErrorCode(se.code()));
       }
+
+      try {
+        CloudSolrClient cloudSolrClient = getCommonCloudSolrClient();
+        cloudSolrClient.add(docs);
+        cloudSolrClient.commit();
+        fail("Expected Bad Request Exception");
+      } catch (SolrException ex) {
+        assertEquals(ErrorCode.BAD_REQUEST, ErrorCode.getErrorCode((ex).code()));
+      }
     }
   }
 }

Modified: lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java?rev=1679122&r1=1679121&r2=1679122&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java (original)
+++ lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java Tue May 12 23:24:25 2015
@@ -619,7 +619,13 @@ public class CloudSolrClient extends Sol
       }
 
       if (exceptions.size() > 0) {
-        throw new RouteException(ErrorCode.SERVER_ERROR, exceptions, routes);
+        Throwable firstException = exceptions.getVal(0);
+        if(firstException instanceof SolrException) {
+          SolrException e = (SolrException) firstException;
+          throw new RouteException(ErrorCode.getErrorCode(e.code()), exceptions, routes);
+        } else {
+          throw new RouteException(ErrorCode.SERVER_ERROR, exceptions, routes);
+        }
       }
     } else {
       for (Map.Entry<String, LBHttpSolrClient.Req> entry : routes.entrySet()) {
@@ -629,7 +635,11 @@ public class CloudSolrClient extends Sol
           NamedList<Object> rsp = lbClient.request(lbRequest).getResponse();
           shardResponses.add(url, rsp);
         } catch (Exception e) {
-          throw new SolrServerException(e);
+          if(e instanceof SolrException) {
+            throw (SolrException) e;
+          } else {
+            throw new SolrServerException(e);
+          }
         }
       }
     }
@@ -928,7 +938,9 @@ public class CloudSolrClient extends Sol
         log.warn("Re-trying request to  collection(s) "+collection+" after stale state error from server.");
         resp = requestWithRetryOnStaleState(request, retryCount+1, collection);
       } else {
-        if (exc instanceof SolrServerException) {
+        if(exc instanceof SolrException) {
+          throw exc;
+        } if (exc instanceof SolrServerException) {
           throw (SolrServerException)exc;
         } else if (exc instanceof IOException) {
           throw (IOException)exc;