[ISSUE #10817] Upgrade SpotBugs for JDK 21 compatibility - #10818
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #10818 +/- ##
=============================================
- Coverage 48.32% 48.24% -0.09%
+ Complexity 13516 13497 -19
=============================================
Files 1380 1380
Lines 101138 101135 -3
Branches 13120 13120
=============================================
- Hits 48876 48792 -84
- Misses 46298 46359 +61
- Partials 5964 5984 +20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
SpotBugs plugin upgrade from 4.2.2 → 4.8.6.8 for JDK 21 compatibility. The old plugin fails on JDK 21 due to deprecated Security Manager API and bundled ASM that can't analyze Java 21 class files.
The newer SpotBugs detects DMI_RANDOM_USED_ONLY_ONCE findings, and the PR correctly addresses them:
- Benchmark
BatchProducer/Producer: one-shotnew Random(System.currentTimeMillis())→ThreadLocalRandom.current()✓ MessageQueueSelector: one-shotnew Random()→ThreadLocalRandom.current()✓NettyRemotingClient.initValueIndex(): one-shotnew Random()→ThreadLocalRandom.current()✓CompactionStore: one-shotnew Random(System.currentTimeMillis())→ThreadLocalRandom.current()✓RandomUtil: removes localRandom rdthat shadowed the class-level field — the loop now correctly uses the shared class-levelrd✓
Removal of obsolete spotbugsXmlOutput parameter is also correct (not supported in 4.8.6.8).
All changes preserve original value ranges and behavior. Verified builds on both JDK 8 and JDK 21.
Automated review by github-manager-bot
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Defensive fix with proper validation and test coverage. LGTM.
Automated review by github-manager-bot
Which Issue(s) This PR Fixes
Brief Description
Upgrade
spotbugs-maven-pluginfrom 4.2.2 to 4.8.6.8 so that SpotBugs can run on JDK 21 while retaining JDK 8 compatibility.The old plugin fails on JDK 21 because it invokes the deprecated Security Manager API and bundles an ASM version that cannot analyze Java 21 class files. This change also removes the obsolete
spotbugsXmlOutputparameter, which is not supported by 4.8.6.8.The newer SpotBugs version detects several High-priority
DMI_RANDOM_USED_ONLY_ONCEfindings. Replace those one-shotRandominstances withThreadLocalRandom, or reuse the existing sharedRandominRandomUtil, while preserving the original value ranges and behavior.How Did You Test This Change?
mvn -B -ntp -Dstyle.color=never -DskipTests compilemvn -B -ntp -Dstyle.color=never -DskipTests clean compileBoth full 19-module reactor builds completed successfully with Checkstyle and SpotBugs reporting no violations.