[hotfix] [metrics] Prevent registration exceptions

Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/19ff8db6
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/19ff8db6
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/19ff8db6

Branch: refs/heads/master
Commit: 19ff8db6847be65c60659e5f6e371fb9dacf1160
Parents: 56cdec7
Author: zentol <ches...@apache.org>
Authored: Wed Jun 15 12:17:22 2016 +0200
Committer: zentol <ches...@apache.org>
Committed: Mon Jun 27 13:08:24 2016 +0200

----------------------------------------------------------------------
 .../org/apache/flink/metrics/MetricRegistry.java    | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/19ff8db6/flink-core/src/main/java/org/apache/flink/metrics/MetricRegistry.java
----------------------------------------------------------------------
diff --git 
a/flink-core/src/main/java/org/apache/flink/metrics/MetricRegistry.java 
b/flink-core/src/main/java/org/apache/flink/metrics/MetricRegistry.java
index 0abcdec..f3402e9 100644
--- a/flink-core/src/main/java/org/apache/flink/metrics/MetricRegistry.java
+++ b/flink-core/src/main/java/org/apache/flink/metrics/MetricRegistry.java
@@ -179,8 +179,12 @@ public class MetricRegistry {
         * @param group       the group that contains the metric
         */
        public void register(Metric metric, String metricName, 
AbstractMetricGroup group) {
-               if (reporter != null) {
-                       reporter.notifyOfAddedMetric(metric, metricName, group);
+               try {
+                       if (reporter != null) {
+                               reporter.notifyOfAddedMetric(metric, 
metricName, group);
+                       }
+               } catch (Exception e) {
+                       LOG.error("Error while registering metric.", e);
                }
        }
 
@@ -192,8 +196,12 @@ public class MetricRegistry {
         * @param group       the group that contains the metric
         */
        public void unregister(Metric metric, String metricName, 
AbstractMetricGroup group) {
-               if (reporter != null) {
-                       reporter.notifyOfRemovedMetric(metric, metricName, 
group);
+               try {
+                       if (reporter != null) {
+                               reporter.notifyOfRemovedMetric(metric, 
metricName, group);
+                       }
+               } catch (Exception e) {
+                       LOG.error("Error while registering metric.", e);
                }
        }
 

Reply via email to