KAFKA-19580 Upgrade to spotbugs 4.9.4 (#20333)

Use Java 24 for the spotbugs checks, now that Spotbugs works  on Java
24.

Added some more warning exclusions for warnings that are new to 4.9.4.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
Stig Døssing 2025-08-10 17:38:15 +02:00 committed by GitHub
parent 43a25043dd
commit 7d2ad18520
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 15 deletions

View File

@ -127,7 +127,7 @@ jobs:
- name: Setup Gradle - name: Setup Gradle
uses: ./.github/actions/setup-gradle uses: ./.github/actions/setup-gradle
with: with:
java-version: 17 java-version: 24
gradle-cache-read-only: ${{ !inputs.is-trunk }} gradle-cache-read-only: ${{ !inputs.is-trunk }}
gradle-cache-write-only: ${{ inputs.is-trunk }} gradle-cache-write-only: ${{ inputs.is-trunk }}
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }} develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}

View File

@ -72,12 +72,6 @@ ext {
"--add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED" "--add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED"
) )
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_24)) {
// Spotbugs is not compatible with Java 24+ until Spotbugs 4.9.4. Disable it until we can upgrade to that version.
project.gradle.startParameter.excludedTaskNames.add("spotbugsMain")
project.gradle.startParameter.excludedTaskNames.add("spotbugsTest")
}
maxTestForks = project.hasProperty('maxParallelForks') ? maxParallelForks.toInteger() : Runtime.runtime.availableProcessors() maxTestForks = project.hasProperty('maxParallelForks') ? maxParallelForks.toInteger() : Runtime.runtime.availableProcessors()
maxScalacThreads = project.hasProperty('maxScalacThreads') ? maxScalacThreads.toInteger() : maxScalacThreads = project.hasProperty('maxScalacThreads') ? maxScalacThreads.toInteger() :
Math.min(Runtime.runtime.availableProcessors(), 8) Math.min(Runtime.runtime.availableProcessors(), 8)

View File

@ -123,10 +123,7 @@ versions += [
scoverage: "2.0.11", scoverage: "2.0.11",
slf4j: "1.7.36", slf4j: "1.7.36",
snappy: "1.1.10.7", snappy: "1.1.10.7",
// While Spotbugs 4.9.3 exists at the time of writing, spotbugs: "4.9.4",
// Spotbugs 4.9.1 is the latest version not affected by https://github.com/spotbugs/spotbugs/pull/3311,
// which breaks the build, so we're sticking with that version until 4.9.4 is released.
spotbugs: "4.9.1",
mockOAuth2Server: "2.2.1", mockOAuth2Server: "2.2.1",
zinc: "1.9.2", zinc: "1.9.2",
// When updating the zstd version, please do as well in docker/native/native-image-configs/resource-config.json // When updating the zstd version, please do as well in docker/native/native-image-configs/resource-config.json

View File

@ -551,7 +551,7 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
</Match> </Match>
<Match> <Match>
<!-- New warning type added when we upgraded from spotbugs 4.8.6 to 4.9.1. <!-- New warning type added when we upgraded from spotbugs 4.8.6 to 4.9.4.
These are possibly real bugs, and have not been evaluated, they were just bulk excluded to unblock upgrading Spotbugs. These are possibly real bugs, and have not been evaluated, they were just bulk excluded to unblock upgrading Spotbugs.
--> -->
<Or> <Or>
@ -586,7 +586,7 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
</Match> </Match>
<Match> <Match>
<!-- New warning type added when we upgraded from spotbugs 4.8.6 to 4.9.1. <!-- New warning type added when we upgraded from spotbugs 4.8.6 to 4.9.4.
These are possibly real bugs, and have not been evaluated, they were just bulk excluded to unblock upgrading Spotbugs. These are possibly real bugs, and have not been evaluated, they were just bulk excluded to unblock upgrading Spotbugs.
--> -->
<Or> <Or>
@ -617,12 +617,16 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
<Class name="kafka.coordinator.transaction.TransactionStateManager"/> <Class name="kafka.coordinator.transaction.TransactionStateManager"/>
<Class name="kafka.log.LogManager"/> <Class name="kafka.log.LogManager"/>
<Class name="kafka.server.ReplicaManager"/> <Class name="kafka.server.ReplicaManager"/>
<Class name="org.apache.kafka.streams.state.internals.AbstractDualSchemaRocksDBSegmentedBytesStore"/>
<Class name="org.apache.kafka.streams.state.internals.AbstractRocksDBSegmentedBytesStore"/>
<Class name="org.apache.kafka.streams.state.internals.InMemorySessionStore"/>
<Class name="org.apache.kafka.streams.state.internals.InMemoryWindowStore"/>
</Or> </Or>
<Bug pattern="AT_NONATOMIC_64BIT_PRIMITIVE"/> <Bug pattern="AT_NONATOMIC_64BIT_PRIMITIVE"/>
</Match> </Match>
<Match> <Match>
<!-- New warning type added when we upgraded from spotbugs 4.8.6 to 4.9.1. <!-- New warning type added when we upgraded from spotbugs 4.8.6 to 4.9.4.
These are possibly real bugs, and have not been evaluated, they were just bulk excluded to unblock upgrading Spotbugs. These are possibly real bugs, and have not been evaluated, they were just bulk excluded to unblock upgrading Spotbugs.
--> -->
<Or> <Or>
@ -687,12 +691,13 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
<Class name="kafka.server.ReplicaManager"/> <Class name="kafka.server.ReplicaManager"/>
<Class name="org.apache.kafka.trogdor.coordinator.NodeManager$NodeHeartbeat"/> <Class name="org.apache.kafka.trogdor.coordinator.NodeManager$NodeHeartbeat"/>
<Class name="org.apache.kafka.connect.runtime.distributed.DistributedHerder$RebalanceListener"/> <Class name="org.apache.kafka.connect.runtime.distributed.DistributedHerder$RebalanceListener"/>
<Class name="org.apache.kafka.streams.processor.internals.StreamThread"/>
</Or> </Or>
<Bug pattern="AT_STALE_THREAD_WRITE_OF_PRIMITIVE"/> <Bug pattern="AT_STALE_THREAD_WRITE_OF_PRIMITIVE"/>
</Match> </Match>
<Match> <Match>
<!-- New warning type added when we upgraded from spotbugs 4.8.6 to 4.9.1. <!-- New warning type added when we upgraded from spotbugs 4.8.6 to 4.9.4.
These are possibly real bugs, and have not been evaluated, they were just bulk excluded to unblock upgrading Spotbugs. These are possibly real bugs, and have not been evaluated, they were just bulk excluded to unblock upgrading Spotbugs.
--> -->
<Or> <Or>
@ -719,4 +724,15 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
<Bug pattern="HSM_HIDING_METHOD"/> <Bug pattern="HSM_HIDING_METHOD"/>
</Match> </Match>
<Match>
<!-- New warning type added when we upgraded from spotbugs 4.8.6 to 4.9.4.
These are possibly real bugs, and have not been evaluated, they were just bulk excluded to unblock upgrading Spotbugs.
-->
<Or>
<Class name="org.apache.kafka.common.security.ssl.SslFactory$SslEngineValidator"/>
<Class name="org.apache.kafka.server.authorizer.Authorizer"/>
</Or>
<Bug pattern="SF_SWITCH_FALLTHROUGH"/>
</Match>
</FindBugsFilter> </FindBugsFilter>