You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2016/03/22 17:40:47 UTC

[2/5] lucene-solr:jira/SOLR-445: SOLR-445: fix exception msg when CloudSolrClient does async updates that (cumulatively) exceed maxErrors

SOLR-445: fix exception msg when CloudSolrClient does async updates that (cumulatively) exceed maxErrors

I initially thought it would make sense to refactor DistributedUpdatesAsyncException into solr-common and re-use it here, but when i started down that path i realized it didn't make any sense since there aren't actual exceptions to wrap client side.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/5d93384e
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/5d93384e
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/5d93384e

Branch: refs/heads/jira/SOLR-445
Commit: 5d93384e724b6f611270e212a4f9bd5b00c38e85
Parents: fe54da0
Author: Chris Hostetter <ho...@apache.org>
Authored: Mon Mar 21 14:36:12 2016 -0700
Committer: Chris Hostetter <ho...@apache.org>
Committed: Mon Mar 21 14:36:12 2016 -0700

----------------------------------------------------------------------
 .../solr/client/solrj/impl/CloudSolrClient.java       | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5d93384e/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
index 37cee8e..edfe1c3 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
@@ -781,14 +781,22 @@ public class CloudSolrClient extends SolrClient {
       if (maxToleratedErrors < toleratedErrors.size()) {
         // cumulative errors are too high, we need to throw a client exception w/correct metadata
 
-        // nocommit: refactor & reuse DistributedUpdatesAsyncException
+        // NOTE: it shouldn't be possible for 1 == toleratedErrors.size(), because if that were the case
+        // then at least one shard should have thrown a real error before this, so we don't worry
+        // about having a more "singular" exception msg for that situation
+        StringBuilder msgBuf =  new StringBuilder()
+          .append(toleratedErrors.size()).append(" Async failures during distributed update: ");
+          
         NamedList metadata = new NamedList<String>();
-        SolrException toThrow = new SolrException(ErrorCode.BAD_REQUEST, "nocommit: better msg from DUAE");
-        toThrow.setMetadata(metadata);
         for (SimpleOrderedMap<String> err : toleratedErrors) {
           ToleratedUpdateError te = ToleratedUpdateError.parseMap(err);
           metadata.add(te.getMetadataKey(), te.getMetadataValue());
+          
+          msgBuf.append("\n").append(te.getMessage());
         }
+        
+        SolrException toThrow = new SolrException(ErrorCode.BAD_REQUEST, msgBuf.toString());
+        toThrow.setMetadata(metadata);
         throw toThrow;
       }
     }