GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [cleanup][misc] Fix javac deprecation and unchecked warnings in main sources by aahmed-se · Pull Request #26257 · apache/pulsar

Conversation

@aahmed-se

@aahmed-se aahmed-se commented Jul 31, 2026 •
edited by merlimat
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Motivation

./gradlew compileJava --rerun-tasks --warning-mode all emits 104 javac warnings on current master. Most come from
deprecations left behind by the Netty 4.2, Guava 33 and commons-lang3 3.20 upgrades, plus 42 copies of
unknown enum constant RequiredMode.REQUIRED, which drown out anything genuinely new in a PR's build log.

This PR removes 60 of them (104 → 44), without changing behaviour. The remaining 44 are newer than this PR
(URL(String), Jetty Version, Thread.getId, Subject.doAs, the same swagger classpath gap in microbench) and are
left for follow-ups.

Modifications

1. Deprecated APIs moved to their documented successors (each checked against the dependency's own sources):

  • CacheBuilder.expireAfterAccess/Write(long, TimeUnit) → the Duration overloads, in NamespaceName,
    PackageName, PulsarClientImpl, AbstractMultiVersionReader, MultiVersionSchemaInfoProvider,
    ConsumerHandler and SimpleLoadManagerImpl.
  • PlatformDependent.threadLocalRandom() → ThreadLocalRandom.current() in PulsarServiceNameResolver (the
    deprecated method's body is exactly that).
  • ChannelOption.RCVBUF_ALLOCATOR → RECVBUF_ALLOCATOR in BrokerService and ProxyService (same object).
  • MutableObject.getValue() → get() in SystemTopicBasedTopicPoliciesService.
  • The deprecated 5-arg PersistentSubscription constructor → the 4-arg one in PersistentTopic; the 5-arg one never
    reads subscriptionProperties. createPersistentSubscription keeps its signature because BrokerTestInterceptor
    overrides it.
  • Removed the EpollChannelOption.EPOLL_MODE call in DirectProxyHandler: Netty 4.2 always uses level-triggered mode
    and documents the option as a no-op.

2. One unchecked-generics fix: ScalableTopicController.prunable collects into a List instead of a generic array.

3. Narrow suppressions where there is no successor yet, each with a comment:

  • intercept(...) in ProducerBuilder / ConsumerBuilder / ReaderBuilder: @SafeVarargs is illegal on an
    abstract method.
  • The three TopicPoliciesService.registerListener overrides are now @Deprecated, matching the interface.
  • AbstractWebSocketHandler.onWebSocketClose(int, String): Jetty 12.1 deprecated it for removal, but moving to the
    3-arg Callback form changes this published class's API. A subclass still overriding the 2-arg form would compile
    and then be rejected at endpoint registration with
    InvalidWebSocketException: Cannot use two versions of onWebSocketClose. The override stays and the [removal]
    warning is suppressed; the migration is left to its own PR, where the API change can be declared.

4. compileOnly(libs.swagger.annotations) in pulsar-client-admin, pulsar-client-v5 and pulsar-testclient.
pulsar-client's configuration-data classes carry runtime-retained @Schema(requiredMode = REQUIRED)
annotations, so javac needs the annotation types to read them. Six modules already declare it this way;
compileOnly reaches neither the runtime classpath nor the published POMs.

Verifying this change

This change is already covered by existing tests:

  • pulsar-websocket (60 tests), NamespaceNameTest, PackageNameTest, PulsarServiceNameResolverTest.
  • ScalableTopicControllerTest, PersistentSubscriptionTest, SimpleLoadManagerImplTest,
    SystemTopicBasedTopicPoliciesServiceTest, LegacyAwareTopicPoliciesServiceTest (115 tests).
  • ./gradlew compileJava --rerun-tasks --warning-mode all: 104 → 44 warnings; ./gradlew quickCheck passes.

Does this pull request potentially affect one of the following parts:

  • Dependencies (add or upgrade a dependency) — compileOnly only, see item 4
  • 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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@aahmed-se @claude
[cleanup][misc] Fix all javac warnings in main sources
57fc85a
`compileJava` emitted 77 warnings across ten modules, mostly deprecations left by
the Netty 4.2, Jetty 12.1, Guava 33 and commons-lang3 3.20 upgrades — including
Jetty's `onWebSocketClose(int, String)`, which is marked for removal.

Moved to the successor APIs: Guava's `Duration` cache overloads,
`RECVBUF_ALLOCATOR`, `ThreadLocalRandom.current()`, `MutableObject.get()`, the
4-arg `PersistentSubscription` constructor and Jetty's 3-arg
`onWebSocketClose`. Dropped the `EPOLL_MODE` call that Netty 4.2 documents as a
no-op. Where no successor exists, suppressed narrowly at the declaration with a
reason. Added `compileOnly(swagger-annotations)` to the three modules that read
`pulsar-client`'s `@Schema` annotations without the types on their compile
classpath.

`compileJava` is now warning-free and `sanityCheck` passes. Test sources still
emit warnings; those are left for a separate change.

Assisted-by: Claude Code (Opus 5)

Co-Authored-By: Claude Opus 5 <[email protected]>
@aahmed-se
aahmed-se requested a review from merlimat July 31, 2026 19:25
@aahmed-se aahmed-se self-assigned this Jul 31, 2026
@aahmed-se
aahmed-se marked this pull request as ready for review July 31, 2026 19:26
lhotari
lhotari previously requested changes Aug 31, 2026
View reviewed changes

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I checked this the way the description invites: every equivalence claim verified against the pinned dependency's own sources rather than taken on trust. They all hold.

Claim Verdict
RCVBUF_ALLOCATOR → RECVBUF_ALLOCATOR Netty 4.2.16 ChannelOption.java:86 declares RCVBUF_ALLOCATOR = RECVBUF_ALLOCATOR — literally the same object
PlatformDependent.threadLocalRandom() → ThreadLocalRandom.current() body is exactly return ThreadLocalRandom.current();
Guava expireAfter*(long, TimeUnit) → (Duration) 33.6.0 delegates to (toNanosSaturated(d), NANOSECONDS); equivalent for every constant used here
MutableObject.getValue() → get() commons-lang3 3.20.0 — getValue() is @Deprecated("Use get()"), same field
5-arg → 4-arg PersistentSubscription ctor the 5-arg body never reads subscriptionProperties; the 4-arg delegates with emptyMap()
EpollChannelOption.EPOLL_MODE removal Netty 4.2.16 getEpollMode() unconditionally returns LEVEL_TRIGGERED; setEpollMode only logs "this is just a no-op"
ScalableTopicController.prunable compiled the new pattern standalone — clean under -Xlint:all; ordering, short-circuit and the empty-list guard preserved
compileOnly(swagger-annotations) not a published scope — the convention plugin's own publishedScopes list excludes it

Two things I checked that the description doesn't mention, both fine: no in-tree subclass of AbstractWebSocketHandler overrides the 2-arg close, and the three test classes that still declare onWebSocketClose(int, String) (ClientSideEncryptionWssProducer/Consumer, ProxyServiceTlsStarterTest) are @OnWebSocketClose-annotated endpoints on Jetty's separate annotated-endpoint path, which this change does not touch.

I also specifically tried and failed to break two things:

  • The @SuppressWarnings("unchecked") on the three abstract intercept(...) declarations is the right category. I expected the non-reifiable-varargs diagnostic to live under varargs and the annotation to be a no-op. It doesn't — javac reports it as [unchecked] Possible heap pollution…, "unchecked" silences it and "varargs" does not. Verified on both build JDKs.
  • The close Callback is not leaked when the handler throws. callback.succeed() isn't in a finally, but JettyWebSocketFrameHandler.notifyOnClose is the only invoker of the close handle and wraps it in catch (Throwable) → callback.failed(...), and both the CLOSE-frame and abnormal-close paths converge there. Pre-PR, CallbackCompletingCloseHolder did the same. No behavioural delta.

That leaves one issue, below. It is not a defect in the code — the code is right and the migration is unavoidable — but it is a real compatibility break that this PR does not declare.

On scope: at +56/−29 this is small and coherent, not the kind of broad mass-refactor the contributing guide warns against, and the mechanical swaps genuinely are [cleanup]. The WebSocket hunk is the exception: it changes a published class's method signature and belongs to a different risk class than the rest of the PR.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-websocket/src/main/java/org/apache/pulsar/websocket/AbstractWebSocketHandler.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

merlimat added 2 commits October 25, 2026 14:14
@merlimat
Merge remote-tracking branch 'apache/master' into fix_warnings
1fd63f2
@merlimat
Keep the 2-arg onWebSocketClose override and suppress its removal war…
ce889ee
…ning

Migrating AbstractWebSocketHandler to onWebSocketClose(int, String, Callback)
changes a published class's API: a subclass that still overrides the 2-arg
form compiles but Jetty rejects it at endpoint registration with
InvalidWebSocketException("Cannot use two versions of onWebSocketClose").
Keep this PR behaviour-neutral and leave that migration to its own change.
@merlimat merlimat changed the title [cleanup][misc] Fix all javac warnings in main sources [cleanup][misc] Fix javac deprecation and unchecked warnings in main sources Oct 25, 2026
@merlimat

merlimat commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Hi @aahmed-se — picking this up as part of the open-PR backlog pass announced on dev@, since it's been idle since lhotari's review. I merged master (dropping the AuthenticationAdapter hunk, since #26282 deleted that file) and took lhotari's option 2. AbstractWebSocketHandler keeps the 2-arg onWebSocketClose with a narrow @SuppressWarnings("removal"), so this PR stays behaviour-neutral, and the Jetty close-callback migration can go in its own PR that declares the API change. On current master this takes compileJava from 104 warnings to 44; the rest are newer and can be follow-ups. Thanks for the careful groundwork. @lhotari, could you take another look?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@merlimat merlimat added this to the 5.1.0 milestone Oct 25, 2026
merlimat
merlimat approved these changes Oct 26, 2026
View reviewed changes
@merlimat
merlimat dismissed lhotari’s stale review October 26, 2026 01:07

Comments addressed

@merlimat
merlimat merged commit bb79dcc into apache:master Oct 26, 2026
44 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@merlimat merlimat mentioned this pull request Oct 26, 2026
[cleanup][misc] Fix the remaining javac warnings in main sources #27113
Merged
lhotari pushed a commit that referenced this pull request Oct 26, 2026
@aahmed-se @claude
@merlimat @lhotari
[cleanup][misc] Fix javac deprecation and unchecked warnings in main …
6055902
…sources (#26257)

Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: Matteo Merli <[email protected]>
(cherry picked from commit bb79dcc)
@lhotari lhotari added release/5.0.2 cherry-picked/branch-5.0 labels Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@merlimat merlimat merlimat approved these changes
@lhotari lhotari lhotari left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@aahmed-se aahmed-se

Labels

cherry-picked/branch-5.0 release/5.0.2

Projects

None yet

Milestone

5.1.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@aahmed-se @merlimat @lhotari
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.