Skip to content

Commit

Permalink
feat(#TOMEE-4267): MicroProfile Metrics JMX Registrar must be initial…
Browse files Browse the repository at this point in the history
…ized once
  • Loading branch information
jeanouii committed Oct 30, 2023
1 parent 654a818 commit 793b7bd
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,23 @@
import org.apache.openejb.util.LogCategory;
import org.apache.openejb.util.Logger;

import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;

public class MPMetricsCDIExtension implements Extension {

private static final AtomicBoolean INIT = new AtomicBoolean(false);

private void afterDeploymentValidation(@Observes final AfterDeploymentValidation avd, BeanManager bm) {
try {
final JmxRegistrar registrar = new JmxRegistrar();
registrar.init();

} catch (final Exception e) {
Logger.getInstance(LogCategory.OPENEJB, MPMetricsCDIExtension.class).error("Can't initialize Metrics Registrar: " + e.getMessage());
if (INIT.compareAndSet(false, true)) {
try {
final JmxRegistrar registrar = new JmxRegistrar();
registrar.init();

} catch (final IOException e) {
Logger.getInstance(LogCategory.OPENEJB, MPMetricsCDIExtension.class).error("Can't initialize Metrics Registrar: " + e.getMessage());
}
}
}

Expand Down

0 comments on commit 793b7bd

Please sign in to comment.