Skip to content

[fix][common] Keep equal-load bundles addressable after sorting#26175

Open
hiSandog wants to merge 1 commit into
apache:masterfrom
hiSandog:fix/pulsar-cleanup-20260711
Open

[fix][common] Keep equal-load bundles addressable after sorting#26175
hiSandog wants to merge 1 commit into
apache:masterfrom
hiSandog:fix/pulsar-cleanup-20260711

Conversation

@hiSandog

Copy link
Copy Markdown
Contributor

Motivation

NamespaceBundleStatsComparator returns a non-zero value when a bundle key is compared with itself. The TreeMap returned by LoadReport.getSortedBundleStats therefore cannot reliably resolve existing entries through get or containsKey, particularly when multiple bundles have equal load statistics.

Modifications

Use the bundle name as a deterministic tie-breaker when load statistics compare equal. This preserves every equal-load bundle while restoring the comparator contract for identical keys.

Add a focused regression test that verifies identical keys compare as equal and both equal-load entries remain addressable in the sorted map.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • env JAVA_HOME=/Applications/IntelliJ\ IDEA.app/Contents/jbr/Contents/Home ./gradlew :pulsar-common:test --tests org.apache.pulsar.common.util.NamespaceBundleStatsComparatorTest -PtestRetryCount=0
  • pulsar-common checkstyleMain, checkstyleTest, and spotlessCheck passed

Does this pull request potentially affect one of the following parts:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

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.

1 participant