Skip to content

Conversation

@3pacccccc
Copy link
Contributor

Motivation

The method AbstractTopic#incrementTopicEpochIfNeeded contains significant code duplication, especially for handling producers in different modes (Exclusive, ExclusiveWithFencing, and WaitForExclusive). This duplication makes the method overly long, harder to read, and more difficult to maintain. The goal of this PR is to improve code readability and maintainability by extracting the duplicated logic into a separate method.

Modifications

Extracted the common logic for handling topic epoch updates and exclusive producer checks into a new method handleTopicEpochForExclusiveProducer.

Replaced the duplicated code blocks in the Exclusive, ExclusiveWithFencing, and WaitForExclusive cases with calls to the new method.

Verifying this change

  • Make sure that the change passes the CI checks.

If the box was checked, please highlight the changes

  • 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

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: 3pacccccc#14

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jul 16, 2025
Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @3pacccccc

@lhotari lhotari changed the title [improve][broker]extract duplicated in AbstractTopic#incrementTopicEpochIfNeeded [improve][broker] Extract duplication in AbstractTopic#incrementTopicEpochIfNeeded Jul 24, 2025
@lhotari lhotari added this to the 4.1.0 milestone Jul 24, 2025
@lhotari lhotari requested a review from codelipenghui July 24, 2025 21:06
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 86.66667% with 4 lines in your changes missing coverage. Please review.

Project coverage is 74.28%. Comparing base (bbc6224) to head (96cebdb).
Report is 1225 commits behind head on master.

Files with missing lines Patch % Lines
...rg/apache/pulsar/broker/service/AbstractTopic.java 86.66% 3 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #24520      +/-   ##
============================================
+ Coverage     73.57%   74.28%   +0.71%     
+ Complexity    32624    32481     -143     
============================================
  Files          1877     1868       -9     
  Lines        139502   145909    +6407     
  Branches      15299    16728    +1429     
============================================
+ Hits         102638   108389    +5751     
- Misses        28908    28918      +10     
- Partials       7956     8602     +646     
Flag Coverage Δ
inttests 26.73% <26.66%> (+2.14%) ⬆️
systests 23.33% <26.66%> (-1.00%) ⬇️
unittests 73.78% <86.66%> (+0.93%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...rg/apache/pulsar/broker/service/AbstractTopic.java 88.36% <86.66%> (+0.37%) ⬆️

... and 1098 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lhotari lhotari requested review from BewareMyPower and dao-jun July 25, 2025 18:48
@Technoboy- Technoboy- merged commit 27df79e into apache:master Jul 29, 2025
100 of 103 checks passed
Technoboy- pushed a commit that referenced this pull request Jul 31, 2025
@3pacccccc 3pacccccc deleted the extractDumplicateCode branch August 7, 2025 11:17
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Aug 14, 2025
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 20, 2025
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Aug 26, 2025
KannarFr pushed a commit to CleverCloud/pulsar that referenced this pull request Sep 22, 2025
walkinggo pushed a commit to walkinggo/pulsar that referenced this pull request Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants