Skip to content

[improve][build] Enable -Xlint:deprecation and -Xlint:unchecked and fix all warnings - #25446

Merged
merlimat merged 2 commits into
apache:masterfrom
merlimat:claude/happy-hoover
Mar 31, 2026
Merged

merlimat merged 2 commits into
apache:masterfrom
merlimat:claude/happy-hoover

Conversation

@merlimat

@merlimat merlimat commented Mar 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Enable -Xlint:deprecation and -Xlint:unchecked compiler flags in pulsar.java-conventions.gradle.kts
  • Fix all ~450+ compilation warnings across 152 files, bringing the count down to 3 unfixable varargs heap pollution warnings on interface methods
  • Suppress -Xlint:-dep-ann for LightProto generated code in pulsar-functions-proto

Categories of fixes:

  • Replace deprecated Commons Lang3 APIs (MutableObject.getValue() β†’ .get(), MutableLong.getValue() β†’ .longValue(), StringUtils.equals(CharSequence) β†’ Objects.equals(), StringUtils.containsIgnoreCase β†’ lowercase comparison)
  • Replace deprecated Guava Charsets.UTF_8 β†’ StandardCharsets.UTF_8
  • Replace deprecated Class.newInstance() β†’ getDeclaredConstructor().newInstance()
  • Add @SuppressWarnings("deprecation") where deprecated APIs are intentionally used (JJWT, Swagger @Api, deprecated interface implementations)
  • Add @SuppressWarnings("unchecked") for raw type casts
  • Fix raw CompletableFuture() β†’ CompletableFuture<>()
  • Remove duplicate @Getter annotations on manually-defined getters

Remaining unfixable warnings (3):

  • ProducerBuilder.intercept(ProducerInterceptor<T>...) β€” varargs heap pollution
  • ConsumerBuilder.intercept(ConsumerInterceptor<T>...) β€” varargs heap pollution
  • ReaderBuilder.intercept(ReaderInterceptor<T>...) β€” varargs heap pollution

These are interface methods where @SafeVarargs cannot be applied (Java language limitation).

Test plan

  • ./gradlew compileJava --rerun-tasks passes with only 3 unfixable warnings
  • CI passes

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

…ix all compilation warnings

Enable `-Xlint:deprecation` and `-Xlint:unchecked` compiler flags across the
project and fix all resulting compilation warnings (~450+), bringing the count
down to 3 unfixable varargs heap pollution warnings on interface methods.

Categories of fixes:
- Replace deprecated Commons Lang3 APIs: `MutableObject.getValue()` β†’ `.get()`,
  `MutableLong.getValue()` β†’ `.longValue()`, `MutableInt.getValue()` β†’ `.intValue()`,
  `MutableDouble.getValue()` β†’ `.doubleValue()`,
  `StringUtils.equals(CharSequence)` β†’ `Objects.equals()`,
  `StringUtils.containsIgnoreCase(CharSequence)` β†’ lowercase comparison
- Replace deprecated Guava `Charsets.UTF_8` β†’ `StandardCharsets.UTF_8`
- Replace deprecated `Class.newInstance()` β†’ `getDeclaredConstructor().newInstance()`
- Add `@SuppressWarnings("deprecation")` where deprecated APIs are intentionally
  used (JJWT, Swagger @Api, deprecated interface implementations)
- Add `@SuppressWarnings("unchecked")` for raw type casts
- Fix raw `CompletableFuture()` β†’ `CompletableFuture<>()`
- Remove duplicate `@Getter` annotations on manually-defined getters
- Suppress `-Xlint:-dep-ann` for LightProto generated code
@merlimat merlimat added area/build doc-not-needed Your PR changes do not impact docs ready-to-test labels Mar 31, 2026
- Sort java.util.Objects and java.io.PrintWriter imports into correct
  alphabetical position
- Break long line in PersistentTopic.java to stay within 120 char limit
@merlimat
merlimat merged commit fabf2f7 into apache:master Mar 31, 2026
80 of 83 checks passed
@merlimat
merlimat deleted the claude/happy-hoover branch March 31, 2026 20:07
@lhotari lhotari added this to the 5.0.0-M1 milestone Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build doc-not-needed Your PR changes do not impact docs ready-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants