Github user rdhabalia commented on a diff in the pull request: https://github.com/apache/incubator-pulsar/pull/521#discussion_r123651843 --- Diff: pulsar-zookeeper/src/main/java/com/yahoo/pulsar/zookeeper/ZooKeeperServerAspect.java --- @@ -31,15 +31,26 @@ */ @Aspect public class ZooKeeperServerAspect { + private static boolean metricsRegistered = false; + @Pointcut("execution(org.apache.zookeeper.server.ZooKeeperServer.new(..))") - public void processRequest() { + public void zkServerConstructorPointCut() { } - @After("processRequest()") - public void timedProcessRequest(JoinPoint joinPoint) throws Throwable { + @After("zkServerConstructorPointCut()") + public void zkServerConstructor(JoinPoint joinPoint) throws Throwable { // ZooKeeperServer instance was created ZooKeeperServer zkServer = (ZooKeeperServer) joinPoint.getThis(); + synchronized (ZooKeeperServerAspect.class) { + if (metricsRegistered) { --- End diff -- > it's not double checked, since the mutex it's upfront :) Oops. yes, my bad.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---