KAFKA-15492: Upgrade and enable spotbugs when building with Java 21 (#14533)
Spotbugs was temporarily disabled as part of KAFKA-15485 to support Kafka build with JDK 21. This PR upgrades the spotbugs version to 4.8.0 which adds support for JDK 21 and enables it's usage on build again.
Reviewers: Divij Vaidya <diviv@amazon.com>
@ -101,7 +102,7 @@ public class FileConfigProvider implements ConfigProvider {
@@ -101,7 +102,7 @@ public class FileConfigProvider implements ConfigProvider {
@ -68,7 +68,7 @@ class LinuxIoMetricsCollector(procRoot: String, val time: Time, val logger: Logg
@@ -68,7 +68,7 @@ class LinuxIoMetricsCollector(procRoot: String, val time: Time, val logger: Logg
@ -46,6 +46,21 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
@@ -46,6 +46,21 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
<Bugpattern="EQ_COMPARETO_USE_OBJECT_EQUALS"/>
</Match>
<Match>
<!-- Disable warnings about constructors that throw exceptions.
CT_CONSTRUCTOR_THROW: Be wary of letting constructors throw exceptions -->
<Bugpattern="CT_CONSTRUCTOR_THROW"/>
</Match>
<Match>
<!-- Disable warnings about identifiers that conflict with standard library identifiers.
PI_DO_NOT_REUSE_PUBLIC_IDENTIFIERS_CLASS_NAMES: Do not reuse public identifiers from JSL as class name
PI_DO_NOT_REUSE_PUBLIC_IDENTIFIERS_FIELD_NAMES: Do not reuse public identifiers from JSL as field name
PI_DO_NOT_REUSE_PUBLIC_IDENTIFIERS_METHOD_NAMES: Do not reuse public identifiers from JSL as method name
<!-- Spotbugs tends to work a little bit better with Java than with Scala. We suppress
some categories of bug reports when using Scala, since spotbugs generates huge
@ -70,7 +85,8 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
@@ -70,7 +85,8 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
NP_ALWAYS_NULL: Null pointer dereference
MS_CANNOT_BE_FINAL: Field isn't final and can't be protected from malicious code
IC_INIT_CIRCULARITY: Initialization circularity
SE_NO_SUITABLE_CONSTRUCTOR: Class is Serializable but its superclass doesn't define a void constructor -->
SE_NO_SUITABLE_CONSTRUCTOR: Class is Serializable but its superclass doesn't define a void constructor
PA_PUBLIC_MUTABLE_OBJECT_ATTRIBUTE: Mutable object-type field is public -->
<Sourcename="~.*\.scala"/>
<Or>
<Bugpattern="NP_LOAD_OF_KNOWN_NULL_VALUE"/>
@ -94,9 +110,16 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
@@ -94,9 +110,16 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
@ -270,6 +293,13 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
@@ -270,6 +293,13 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
<!-- JMH benchmarks often have fields that are modified by the framework.
SS_SHOULD_BE_STATIC: Unread field: should this field be static? -->
<Packagename="~org\.apache\.kafka\.jmh\..*"/>
<Bugpattern="SS_SHOULD_BE_STATIC"/>
</Match>
<Match>
<!-- Suppress warnings about generated schema arrays. -->
<Or>
@ -367,6 +397,16 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
@@ -367,6 +397,16 @@ For a detailed description of spotbugs bug categories, see https://spotbugs.read
</Or>
</Match>
<Match>
<!-- Public mutable fields are intentional in some Streams classes.
PA_PUBLIC_PRIMITIVE_ATTRIBUTE: Primitive field is public -->
@ -71,7 +71,7 @@ public class FileBasedStateStore implements QuorumStateStore {
@@ -71,7 +71,7 @@ public class FileBasedStateStore implements QuorumStateStore {
@ -107,7 +108,7 @@ public class ReplicatedCounter implements RaftClient.Listener<Integer> {
@@ -107,7 +108,7 @@ public class ReplicatedCounter implements RaftClient.Listener<Integer> {
}
log.debug("Counter incremented from {} to {}",initialCommitted,committed);