[refactor][broker]introduce private methods to remove clones#25550
[refactor][broker]introduce private methods to remove clones#25550aaaZayne wants to merge 1 commit intoapache:masterfrom
Conversation
| String path = MANAGED_LEDGER_PATH + "/" + ns; | ||
| log.info().attr("namespace", ns).attr("path", path).log("Clearing namespace persistence for namespace: , path"); | ||
| return store.deleteIfExists(path, Optional.empty()); | ||
| return clearManagedLedgerPathIfExistsAsync(ns, MANAGED_LEDGER_PATH + "/" + ns, | ||
| "Clearing namespace persistence for namespace: , path"); | ||
| } | ||
|
|
||
| public CompletableFuture<Void> clearDomainPersistence(NamespaceName ns) { | ||
| String path = MANAGED_LEDGER_PATH + "/" + ns + "/persistent"; | ||
| log.info().attr("namespace", ns).attr("path", path).log("Clearing domain persistence for namespace: , path"); | ||
| return clearManagedLedgerPathIfExistsAsync(ns, MANAGED_LEDGER_PATH + "/" + ns + "/persistent", | ||
| "Clearing domain persistence for namespace: , path"); | ||
| } | ||
|
|
||
| private CompletableFuture<Void> clearManagedLedgerPathIfExistsAsync( | ||
| NamespaceName ns, String path, String logMessage) { | ||
| log.info().attr("namespace", ns).attr("path", path).log(logMessage); |
There was a problem hiding this comment.
This refactoring isn't that useful since the method name clearManagedLedgerPathIfExistsAsync isn't accurate. The path is a MetadataStore path, exactly what store.deleteIfExists already handles.
Eliminating duplication for the log message isn't useful since it just results in harder readability.
lhotari
left a comment
There was a problem hiding this comment.
I've added a comment about the other refactoring.
To be honest, there are hundreds or thousands of similar code duplications in Pulsar, and opening PRs for each of them would create more burden for maintainers than the refactorings provide in value. If you have a larger refactoring in mind, please bring it up on the dev@pulsar.apache.org mailing list to discuss the proposed changes before investing significant effort. In the age of AI agents, it's easy to generate large volumes of refactoring PRs, and the project may need to push back on such contributions when they risk overwhelming maintainers. In general, we aren't interested in contributions from people who aren't actually using Apache Pulsar and are simply using AI agents to generate PRs across OSS projects.
In your case, your GitHub profile doesn't identify you. Larger contributions from anonymous profiles will typically be rejected, since we need a real person taking responsibility for the changes rather than dealing with unattributed AI agent contributions.
Motivation
introduce private methods to remove clones
Modifications
Refactor path validation methods in NamespaceResources and TopicResources for better readability and reusability
Verifying this change
This change is a trivial rework / code cleanup without any test coverage.
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes