You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ij...@apache.org on 2018/11/27 22:40:26 UTC
[kafka] branch trunk updated: KAFKA-7389: Enable spotBugs with Java
11 and disable false positive warnings (#5943)
This is an automated email from the ASF dual-hosted git repository.
ijuma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 0ee1635 KAFKA-7389: Enable spotBugs with Java 11 and disable false positive warnings (#5943)
0ee1635 is described below
commit 0ee16350ac2e1ac7fa16f276ae61d2899eaaf28e
Author: Ismael Juma <is...@juma.me.uk>
AuthorDate: Tue Nov 27 14:40:17 2018 -0800
KAFKA-7389: Enable spotBugs with Java 11 and disable false positive warnings (#5943)
See https://github.com/spotbugs/spotbugs/issues/756 for details on
the false positives affecting try with resources. An example is:
> RCN | Nullcheck of fc at line 629 of value previously dereferenced in
> org.apache.kafka.common.utils.Utils.readFileAsString(String, Charset)
Reviewers: Manikumar Reddy <ma...@gmail.com>
---
build.gradle | 27 ++++++++++++---------------
gradle/spotbugs-exclude.xml | 11 +++++++++++
2 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/build.gradle b/build.gradle
index 5ce648a..d9816a1 100644
--- a/build.gradle
+++ b/build.gradle
@@ -149,8 +149,7 @@ subprojects {
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'checkstyle'
- if (!JavaVersion.current().isJava11Compatible())
- apply plugin: "com.github.spotbugs"
+ apply plugin: "com.github.spotbugs"
sourceCompatibility = minJavaVersion
targetCompatibility = minJavaVersion
@@ -372,20 +371,18 @@ subprojects {
}
test.dependsOn('checkstyleMain', 'checkstyleTest')
- if (!JavaVersion.current().isJava11Compatible()) {
- spotbugs {
- toolVersion = '3.1.8'
- excludeFilter = file("$rootDir/gradle/spotbugs-exclude.xml")
- ignoreFailures = false
- }
- test.dependsOn('spotbugsMain')
+ spotbugs {
+ toolVersion = '3.1.8'
+ excludeFilter = file("$rootDir/gradle/spotbugs-exclude.xml")
+ ignoreFailures = false
+ }
+ test.dependsOn('spotbugsMain')
- tasks.withType(com.github.spotbugs.SpotBugsTask) {
- reports {
- // Continue supporting `xmlFindBugsReport` for compatibility
- xml.enabled(project.hasProperty('xmlSpotBugsReport') || project.hasProperty('xmlFindBugsReport'))
- html.enabled(!project.hasProperty('xmlSpotBugsReport') && !project.hasProperty('xmlFindBugsReport'))
- }
+ tasks.withType(com.github.spotbugs.SpotBugsTask) {
+ reports {
+ // Continue supporting `xmlFindBugsReport` for compatibility
+ xml.enabled(project.hasProperty('xmlSpotBugsReport') || project.hasProperty('xmlFindBugsReport'))
+ html.enabled(!project.hasProperty('xmlSpotBugsReport') && !project.hasProperty('xmlFindBugsReport'))
}
}
diff --git a/gradle/spotbugs-exclude.xml b/gradle/spotbugs-exclude.xml
index d83c4c4..a954baf 100644
--- a/gradle/spotbugs-exclude.xml
+++ b/gradle/spotbugs-exclude.xml
@@ -23,6 +23,17 @@ This file dictates which categories of bugs and individual false positives that
For a detailed description of spotbugs bug categories, see https://spotbugs.readthedocs.io/en/latest/bugDescriptions.html
-->
<FindBugsFilter>
+
+ <!-- false positive in Java 11, see https://github.com/spotbugs/spotbugs/issues/756 -->
+ <Match>
+ <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
+ </Match>
+
+ <!-- false positive in Java 11, see https://github.com/spotbugs/spotbugs/issues/756 -->
+ <Match>
+ <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/>
+ </Match>
+
<Match>
<!-- Disable warnings about mutable objects and the use of public fields.
EI_EXPOSE_REP: May expose internal representation by returning reference to mutable object