commit | 11497e88ecb1b8399b058abf45c80f5494906cc5 | [log] [tgz] |
---|---|---|
author | David Pursehouse <dpursehouse@collab.net> | Fri Mar 17 14:55:00 2017 +0900 |
committer | David Pursehouse <dpursehouse@collab.net> | Fri Mar 17 14:55:00 2017 +0900 |
tree | af4bc46cabe1858e713264b4be77cd0cf9c8b254 | |
parent | 6b2a9cf363a963dbb333fddb22a0f471cf3468d2 [diff] |
Prevent starting the reporter twice If the start() method is called twice, the reporter will throw an IllegalArgumentException and the plugin will fail to load. Catch this case and log a warning. This is a workaround for issue 5806. Change-Id: Ic7134381fdf8173a30cf575a40a67dcc04921247
diff --git a/src/main/java/com/googlesource/gerrit/plugins/metricsreporters/GerritGraphiteReporter.java b/src/main/java/com/googlesource/gerrit/plugins/metricsreporters/GerritGraphiteReporter.java index 6ac9db2..319ece0 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/metricsreporters/GerritGraphiteReporter.java +++ b/src/main/java/com/googlesource/gerrit/plugins/metricsreporters/GerritGraphiteReporter.java
@@ -118,7 +118,16 @@ @Override public void start() { if (graphiteReporter != null) { - graphiteReporter.start(rate, DEFAULT_RATE_UNIT); + try { + graphiteReporter.start(rate, DEFAULT_RATE_UNIT); + } catch (IllegalArgumentException e) { + String msg = e.getMessage(); + if ("Reporter already started".equals(msg)) { + log.warn(msg); + } else { + throw e; + } + } } }