Repository navigation
[improve][build] Enable -Xlint:deprecation and -Xlint:unchecked and fix all warnings - #25446
Merged
Merged
Conversation
β¦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
lhotari
approved these changes
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
-Xlint:deprecationand-Xlint:uncheckedcompiler flags inpulsar.java-conventions.gradle.kts-Xlint:-dep-annfor LightProto generated code inpulsar-functions-protoCategories of fixes:
MutableObject.getValue()β.get(),MutableLong.getValue()β.longValue(),StringUtils.equals(CharSequence)βObjects.equals(),StringUtils.containsIgnoreCaseβ lowercase comparison)Charsets.UTF_8βStandardCharsets.UTF_8Class.newInstance()βgetDeclaredConstructor().newInstance()@SuppressWarnings("deprecation")where deprecated APIs are intentionally used (JJWT, Swagger@Api, deprecated interface implementations)@SuppressWarnings("unchecked")for raw type castsCompletableFuture()βCompletableFuture<>()@Getterannotations on manually-defined gettersRemaining unfixable warnings (3):
ProducerBuilder.intercept(ProducerInterceptor<T>...)β varargs heap pollutionConsumerBuilder.intercept(ConsumerInterceptor<T>...)β varargs heap pollutionReaderBuilder.intercept(ReaderInterceptor<T>...)β varargs heap pollutionThese are interface methods where
@SafeVarargscannot be applied (Java language limitation).Test plan
./gradlew compileJava --rerun-taskspasses with only 3 unfixable warningsDocumentation
docdoc-requireddoc-not-neededdoc-complete