Add explicit system module to avoid getting start/stop called twice Due to the bug 2106 a LifecycleListener's start/stop method are called twice. As documented in 2106, this only happens when there are no explicitly defined modules and modules are automatically generated. Change-Id: I1ed0f7f855401de9410785664566c5d9e8edae3e
diff --git a/BUILD b/BUILD index 1013c5e..9fbbd36 100644 --- a/BUILD +++ b/BUILD
@@ -5,6 +5,7 @@ srcs = glob(["src/main/java/**/*.java"]), manifest_entries = [ "Gerrit-PluginName: metrics-reporter-jmx", + "Gerrit-Module: com.googlesource.gerrit.plugins.metricsreporterjmx.Module", ], resources = glob(["src/main/resources/**/*"]), deps = ["@metrics_jmx//jar"],
diff --git a/src/main/java/com/googlesource/gerrit/plugins/metricsreporterjmx/Module.java b/src/main/java/com/googlesource/gerrit/plugins/metricsreporterjmx/Module.java new file mode 100644 index 0000000..aa9d1df --- /dev/null +++ b/src/main/java/com/googlesource/gerrit/plugins/metricsreporterjmx/Module.java
@@ -0,0 +1,24 @@ +// Copyright (C) 2020 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.googlesource.gerrit.plugins.metricsreporterjmx; + +import com.google.gerrit.lifecycle.LifecycleModule; + +public class Module extends LifecycleModule { + @Override + protected void configure() { + listener().to(GerritJmxReporter.class); + } +}