MukundaKatta opened a new pull request, #1134:
URL: https://github.com/apache/pulsar-site/pull/1134
## Why
Reported in apache/pulsar#23246: several Java code samples in the client
docs do not compile (missing semicolons, deprecated method overloads,
incomplete interface implementations, syntax errors). New users copying these
snippets straight into an IDE see immediate errors.
## What
Three docs files, narrowly scoped fixes; no behavior or wording changes
beyond the snippet bodies.
- `client-libraries/java-use.md`
- Add the missing `;` after the `MessageListener` lambda assignment.
- Switch raw `Consumer` / `Message` / `Reader` to `Consumer<byte[]>` /
`Message<byte[]>` / `Reader<byte[]>` so the snippets compile cleanly (no
raw-type warnings).
- `client-libraries/consumers.md`
- Add the missing `;` after `.subscribe()` in the Exclusive / Failover /
Shared / Key_Shared examples.
- Switch raw `Consumer` to `Consumer<byte[]>` for the same reason.
- Fix `conumser` typo and a stray double space in an inline comment.
- `client-libraries/producers.md`
- Update the `MessageRouter` example to implement the non-deprecated
`choosePartition(Message<?>, TopicMetadata)` overload (the single-argument form
has been deprecated since 1.22.0; see
`pulsar-client-api/src/main/java/org/apache/pulsar/client/api/MessageRouter.java`).
- Fix the `ProducerInterceptor` snippet: was `new ProducerInterceptor {`
with a missing `()`, no `close()` implementation, `beforeSend` had no `return`,
and used raw types. Now matches the current
`org.apache.pulsar.client.api.interceptor.ProducerInterceptor` interface so it
compiles.
Examples still demonstrate the same concepts; only the Java source is
corrected.
## Tested
- Manually compiled the corrected Java snippets against `pulsar-client-api`
4.0.x; all four updated examples (MessageListener block,
Failover/Shared/Key_Shared consumers, MessageRouter, ProducerInterceptor)
compile without errors or raw-type warnings.
- Did not run the docs site build locally; only Markdown content inside
fenced ``` ```java ``` blocks was changed, no front-matter, sidebar, or
component edits.
## Out of scope (follow-ups welcome)
The reporter did not enumerate snippets, so this PR fixes the most clearly
broken Java examples in the core "client libraries" pages. There are likely
similar polish opportunities in adjacent pages (`schema-*.md`,
`cookbooks-*.md`, `transactions.md`, etc.); happy to do follow-up PRs if a
maintainer points to a specific page.
Closes apache/pulsar#23246
--
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]