BewareMyPower opened a new issue, #25019: URL: https://github.com/apache/pulsar/issues/25019
### Search before reporting - [x] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar. ### Motivation See https://github.com/apache/pulsar/pull/25016#discussion_r2560288325 Since https://github.com/apache/pulsar/pull/24622, when a managed ledger does not inherit `ManagedLedgerImpl`, the expiration check will use a different method, which is hard to test without a custom implementation. ```java if (managedLedger instanceof ManagedLedgerImpl ml) { checkMessageExpiryWithSharedPosition(ml, messageTtlInSeconds); } else { // Fallback to the slower solution if managed ledger is not an instance of ManagedLedgerImpl: each // subscription find position and handle expiring itself. checkMessageExpiryWithoutSharedPosition(messageTtlInSeconds); } ``` However, in `checkMessageExpiryWithSharedPosition`, the only operation is getting the cursor with oldest position: ```java private void checkMessageExpiryWithSharedPosition(ManagedLedgerImpl ml, int messageTtlInSeconds) { // Find the target position at one time, then expire all subscriptions and replicators. final var cursorWithOldestPosition = ml.getCursors().getCursorWithOldestPosition(); ``` This should be a general operation that if the `ManagedLedger#getCursors` returns a correct cursor container, it should also work even if it's not a `ManagedLedgerImpl`. ### Solution _No response_ ### Alternatives _No response_ ### Anything else? _No response_ ### Are you willing to submit a PR? - [ ] I'm willing to submit a PR! -- 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]
