codelipenghui opened a new pull request, #25298:
URL: https://github.com/apache/pulsar/pull/25298

   ## Summary
   - Replace inline `NoSuchLedgerExists` checks with 
`Errors.isNoSuchLedgerExistsException()` in `ManagedLedgerFactoryImpl` and 
`ManagedLedgerImpl`
   - Refactor `createManagedLedgerException(Throwable)` to use 
`FutureUtil.unwrapCompletionException()` with proper null guards
   - Simplify `NullLedgerOffloader` to use `FutureUtil.failedFuture()`
   - Extract duplicated add-completion logic in `OpAddEntry` into 
`completeAdd()` method
   - Extract duplicated range removal in `RangeEntryCacheImpl` into 
`removeRangeAndNotify()` method
   
   ## Motivation
   Reduce code duplication and improve maintainability across the 
managed-ledger module by consolidating repeated patterns into shared utility 
methods.
   
   ## Modifications
   - **ManagedLedgerFactoryImpl**: Use 
`Errors.isNoSuchLedgerExistsException(rc)` instead of inline checks
   - **ManagedLedgerImpl**: Remove private `isLedgerNotExistException()`, use 
shared `Errors.isNoSuchLedgerExistsException()`; refactor 
`createManagedLedgerException(Throwable)` to use 
`FutureUtil.unwrapCompletionException()` with null guards for both input and 
unwrapped cause
   - **NullLedgerOffloader**: Replace manual `CompletableFuture` + 
`completeExceptionally` with `FutureUtil.failedFuture()`
   - **OpAddEntry**: Extract duplicated callback-notify-release-recycle pattern 
from `addComplete`/`closeComplete` into `completeAdd()`
   - **RangeEntryCacheImpl**: Extract duplicated `removeRange` + 
`entriesRemoved` into `removeRangeAndNotify()`, with DEBUG log preserved in 
`invalidateAllEntries` and TRACE in the shared method
   
   ## Verifying this change
   This is a refactoring change with no behavioral modifications (except 
improved null handling in `createManagedLedgerException`). Existing tests 
should cover all affected code paths.
   
   ## Documentation
   - [ ] `doc-required`
     Check the box above or label this PR directly if your changes impact 
documentation.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to