Skip to content

[fix][client] PIP-468: V5 client validates serviceUrl scheme#25720

Open
merlimat wants to merge 1 commit intoapache:masterfrom
merlimat:v5-validate-service-url
Open

[fix][client] PIP-468: V5 client validates serviceUrl scheme#25720
merlimat wants to merge 1 commit intoapache:masterfrom
merlimat:v5-validate-service-url

Conversation

@merlimat
Copy link
Copy Markdown
Contributor

@merlimat merlimat commented May 8, 2026

Summary

The v5 client only speaks the broker binary protocol; passing the admin/web service URL (http:// or https://) used to silently accept the value and then fail far downstream with a cryptic connection error. This PR validates the URL at configure-time and fails fast with a message that points to the right URL.

  • PulsarClientBuilder.serviceUrl() and ConnectionPolicy.proxyServiceUrl must use pulsar:// or pulsar+ssl://. Anything else throws IllegalArgumentException at the setter.
  • The error message for http:// / https:// specifically calls out the admin-URL confusion and hints at the broker port (6650 / 6651).
  • API javadoc updated to document the contract and the @throws.

Test plan

  • New PulsarClientBuilderV5Test covers:
    • Accepted forms: pulsar://host:port, pulsar+ssl://host:port, multi-host comma list (pulsar://h1:p,h2:p,h3:p)
    • Rejected schemes: http:// (with admin-URL guidance + port hint), https:// (with TLS-broker-scheme hint), ws://, null, blank
    • ConnectionPolicy.proxyServiceUrl is validated too
  • All pulsar-client-v5 unit tests pass
  • Checkstyle clean

The v5 client only speaks the broker binary protocol; passing the admin/web
service URL (http:// or https://) used to silently accept the value and
then fail far downstream with a cryptic connection error. Validate at
configure-time and fail with a message that points to the right URL:

- PulsarClientBuilder.serviceUrl() and ConnectionPolicy.proxyServiceUrl
  must use pulsar:// or pulsar+ssl://. Anything else throws
  IllegalArgumentException at the setter.
- The error message for http:// / https:// specifically calls out the
  admin-URL confusion and hints at the broker port (6650 / 6651).
- API javadoc updated to document the contract and the @throws.
- New PulsarClientBuilderV5Test covers accepted forms (single host, TLS,
  multi-host comma list) and each rejected case (http, https, unknown
  scheme, null, blank), plus that proxyServiceUrl is validated too.
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.

1 participant