You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2017/03/30 11:39:57 UTC

[26/31] lucene-solr:feature/autoscaling: SOLR-10362 Be more specific when catching this exception.

SOLR-10362 Be more specific when catching this exception.


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

Branch: refs/heads/feature/autoscaling
Commit: 1d8193c7c94bdc99b0b10c6a95dfa2660bd5755b
Parents: 83bea83
Author: Andrzej Bialecki <ab...@apache.org>
Authored: Wed Mar 29 14:42:20 2017 +0200
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Mar 30 17:09:07 2017 +0530

----------------------------------------------------------------------
 .../src/java/org/apache/solr/util/stats/MetricUtils.java     | 8 ++++++--
 .../src/test/org/apache/solr/util/stats/MetricUtilsTest.java | 8 ++++----
 2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1d8193c7/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java b/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java
index 9809070..491932d 100644
--- a/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java
+++ b/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java
@@ -215,8 +215,12 @@ public class MetricUtils {
             try {
               consumer.accept(n, convertGauge(gauge, compact));
             } catch (InternalError ie) {
-              LOG.warn("Error converting gauge '" + n + "', possible JDK bug: SOLR-10362", ie);
-              consumer.accept(n, null);
+              if (n.startsWith("memory.") && ie.getMessage().contains("Memory Pool not found")) {
+                LOG.warn("Error converting gauge '" + n + "', possible JDK bug: SOLR-10362", ie);
+                consumer.accept(n, null);
+              } else {
+                throw ie;
+              }
             }
           } else if (metric instanceof Meter) {
             Meter meter = (Meter) metric;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1d8193c7/solr/core/src/test/org/apache/solr/util/stats/MetricUtilsTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/util/stats/MetricUtilsTest.java b/solr/core/src/test/org/apache/solr/util/stats/MetricUtilsTest.java
index fe98157..aa02de5 100644
--- a/solr/core/src/test/org/apache/solr/util/stats/MetricUtilsTest.java
+++ b/solr/core/src/test/org/apache/solr/util/stats/MetricUtilsTest.java
@@ -81,8 +81,8 @@ public class MetricUtilsTest extends SolrTestCaseJ4 {
     am.set("bar", 2);
     Gauge<String> gauge = () -> "foobar";
     registry.register("gauge", gauge);
-    Gauge<Long> error = () -> {throw new InternalError("expected error");};
-    registry.register("expected.error", error);
+    Gauge<Long> error = () -> {throw new InternalError("Memory Pool not found error");};
+    registry.register("memory.expected.error", error);
     MetricUtils.toMaps(registry, Collections.singletonList(MetricFilter.ALL), MetricFilter.ALL,
         false, false, false, (k, o) -> {
       Map v = (Map)o;
@@ -108,7 +108,7 @@ public class MetricUtilsTest extends SolrTestCaseJ4 {
         update = (Map<String, Object>)values.get("bar");
         assertEquals(2, update.get("value"));
         assertEquals(2, update.get("updateCount"));
-      } else if (k.startsWith("expected.error")) {
+      } else if (k.startsWith("memory.expected.error")) {
         assertNull(v);
       }
     });
@@ -147,7 +147,7 @@ public class MetricUtilsTest extends SolrTestCaseJ4 {
             update = (Map<String, Object>)values.get("bar");
             assertEquals(2, update.get("value"));
             assertEquals(2, update.get("updateCount"));
-          } else if (k.startsWith("expected.error")) {
+          } else if (k.startsWith("memory.expected.error")) {
             assertNull(o);
           } else {
             Map v = (Map)o;