xiangwangcheng commented on issue #515: org.apache.rocketmq.common.stats.StatsItemSet#getAndCreateStatsItem has multi-thread problem URL: https://github.com/apache/rocketmq/issues/515#issuecomment-435057848 Use putIfAbsent will solve this problem. ``` public StatsItem getAndCreateStatsItem(final String statsKey) { StatsItem statsItem = this.statsItemTable.get(statsKey); if (null == statsItem) { statsItem = new StatsItem(this.statsName, statsKey, this.scheduledExecutorService, this.log); StatsItem prev = this.statsItemTable.putIfAbsent(statsKey, statsItem); if (null != prev) { statsItem = prev; // statsItem.init(); } } return statsItem; } ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
