Skip to content

[refactor][broker]introduce private methods to remove clones#25550

Open
aaaZayne wants to merge 1 commit intoapache:masterfrom
aaaZayne:clone-revise
Open

[refactor][broker]introduce private methods to remove clones#25550
aaaZayne wants to merge 1 commit intoapache:masterfrom
aaaZayne:clone-revise

Conversation

@aaaZayne
Copy link
Copy Markdown

Motivation

introduce private methods to remove clones

Modifications

Refactor path validation methods in NamespaceResources and TopicResources for better readability and reusability

Verifying this change

  • Make sure that the change passes the CI checks.

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

  • 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

Comment on lines -93 to +104
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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
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.

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.

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.

2 participants