Skip to content

Replace deprecated StatsImpl.addStatistic with addStatistics(Set.of(..))#2061

Closed
trex-amazon wants to merge 1 commit into
apache:mainfrom
trex-amazon:refactor/1984-batch-addstatistics
Closed

Replace deprecated StatsImpl.addStatistic with addStatistics(Set.of(..))#2061
trex-amazon wants to merge 1 commit into
apache:mainfrom
trex-amazon:refactor/1984-batch-addstatistics

Conversation

@trex-amazon
Copy link
Copy Markdown

Summary

StatsImpl.addStatistic(String, StatisticImpl) is marked @Deprecated(forRemoval = true, since = "6.2.0"), and its String name argument is unused (the method simply adds the statistic to the backing set). This PR replaces the remaining call sites in the broker statistics classes with the batched addStatistics(Collection) API.

This follows the pattern already adopted in the activemq-client management classes (e.g. JMSSessionStatsImpl, JCAConnectionPoolStatsImpl), and finishes migrating the broker-side StatsImpl subclasses off the deprecated method.

Fixes #1984

Changes

Each constructor now registers its statistics in a single addStatistics(Set.of(...)) call instead of multiple addStatistic("name", stat) calls. Eight classes in activemq-broker:

  • broker/region/ConnectionStatistics
  • broker/region/ConnectorStatistics
  • broker/region/RegionStatistics
  • broker/region/SubscriptionStatistics
  • network/NetworkBridgeStatistics
  • store/AbstractMessageStoreStatistics
  • store/MessageStoreStatistics
  • store/PersistenceAdapterStatistics

Behavioral impact

None. The statistics are stored in the same backing set; only the redundant (ignored) name argument and the deprecated call are removed. No public API changes, no new files.

Testing

  • mvn clean compile on activemq-broker (JDK 17) — builds clean; the previously-emitted deprecation warnings for these classes are gone.
  • Statistics/management tests pass: NetworkAdvancedStatisticsTest, BrokerStatisticsPluginTest, AbstractInflightMessageSizeTest, and the full org.apache.activemq.management.* / org.apache.activemq.statistics.* packages.

StatsImpl.addStatistic(String, StatisticImpl) is marked
@deprecated(forRemoval = true, since = "6.2.0") and its String name
argument is unused. Replace the remaining call sites in the broker
statistics classes with the batched addStatistics(Collection) API,
following the pattern already adopted in the activemq-client management
classes (e.g. JMSSessionStatsImpl).

Pure mechanical refactor: each constructor now registers its statistics
in a single addStatistics(Set.of(...)) call. No behavioral change -- the
statistics are stored in the same backing set; only the redundant,
ignored name argument and the deprecated call are removed.

Fixes apache#1984
@jbonofre jbonofre self-requested a review May 31, 2026 06:46
@mattrpav
Copy link
Copy Markdown
Contributor

Closing, as this is a duplicate of #1985

@mattrpav mattrpav closed this May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor use of deprecated StatsImpl.addStatistic to use addStatistics(Set.of(..))

2 participants