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/12 01:27:17 UTC

[36/50] [abbrv] lucene-solr git commit: SOLR-445: fix my silly mistake with the merged exception metadata

SOLR-445: fix my silly mistake with the merged exception metadata


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

Branch: refs/heads/jira/SOLR-445
Commit: 0ccee15624d75d305aa3ab4d0b3c2dc5d93d8fea
Parents: b24fb02
Author: Chris Hostetter <ho...@apache.org>
Authored: Thu Mar 10 16:30:36 2016 -0700
Committer: Chris Hostetter <ho...@apache.org>
Committed: Thu Mar 10 16:30:36 2016 -0700

----------------------------------------------------------------------
 .../processor/DistributedUpdateProcessor.java   | 34 ++++++++------------
 .../processor/TolerantUpdateProcessor.java      | 14 +++++++-
 2 files changed, 27 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ccee156/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
index 105d3ff..01aa38b 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
@@ -1702,26 +1702,20 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
       super(buildCode(errors), buildMsg(errors), null);
       this.errors = errors;
 
-      // nocommit: the code below is useful for preserving things like "root-error-class"
-      // nocommit: but wreaks havoc on ToleranteUpdateProcessor's exception annotating.
-      //
-      // nocommit: before enabling the code below, we need to make ToleranteUpdateProcessor 
-      // nocommit: smart enough to remove metadata it cares about before adding it (and others) back
-      //
-      // // create a merged copy of the metadata from all wrapped exceptions
-      // NamedList<String> metadata = new NamedList<String>();
-      // for (Error error : errors) {
-      //   if (error.e instanceof SolrException) {
-      //     SolrException e = (SolrException) error.e;
-      //     NamedList<String> eMeta = e.getMetadata();
-      //     if (null != eMeta) {
-      //       metadata.addAll(eMeta);
-      //     }
-      //   }
-      // }
-      // if (0 < metadata.size()) {
-      //   this.setMetadata(metadata);
-      // }
+      // create a merged copy of the metadata from all wrapped exceptions
+      NamedList<String> metadata = new NamedList<String>();
+      for (Error error : errors) {
+        if (error.e instanceof SolrException) {
+          SolrException e = (SolrException) error.e;
+          NamedList<String> eMeta = e.getMetadata();
+          if (null != eMeta) {
+            metadata.addAll(eMeta);
+          }
+        }
+      }
+      if (0 < metadata.size()) {
+        this.setMetadata(metadata);
+      }
     }
 
     /** Helper method for constructor */

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ccee156/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java
index a858e92..40e9b23 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessor.java
@@ -217,7 +217,7 @@ public class TolerantUpdateProcessor extends UpdateRequestProcessor {
       firstErrTracker.caught(duae);
 
       
-      // adjust out stats based on the distributed errors
+      // adjust our stats based on each of the distributed errors
       for (Error error : duae.errors) {
         // we can't trust the req info from the Error, because multiple original requests might have been
         // lumped together
@@ -373,6 +373,18 @@ public class TolerantUpdateProcessor extends UpdateRequestProcessor {
       if (null == firstErrMetadata) { // obnoxious
         firstErrMetadata = new NamedList<String>();
         first.setMetadata(firstErrMetadata);
+      } else {
+        // any existing metadata representing ToleratedUpdateErrors in this single exception needs removed
+        // so we can add *all* of the known ToleratedUpdateErrors (from this and other exceptions)
+        for (int i = 0; i < firstErrMetadata.size(); i++) {
+          if (null != ToleratedUpdateError.parseMetadataIfToleratedUpdateError
+              (firstErrMetadata.getName(i), firstErrMetadata.getVal(i))) {
+               
+            firstErrMetadata.remove(i);
+            // NOTE: post decrementing index so we don't miss anything as we remove items
+            i--;
+          }
+        }
       }
 
       for (ToleratedUpdateError te : errors) {