kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject [kafka] 02/02: KAFKA-7389: Enable spotBugs with Java 11 and disable false positive warnings (#5943)
Date Fri, 30 Nov 2018 15:26:53 GMT
This is an automated email from the ASF dual-hosted git repository.

ijuma pushed a commit to branch spotbugs-java11-2.1
in repository https://gitbox.apache.org/repos/asf/kafka.git

commit 36fff71d7f0b5fe2cd73d3ad9ba4908eea276620
Author: Ismael Juma <ismael@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 <manikumar.reddy@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 bba3d83..98b0e38 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
@@ -367,20 +366,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


Mime
View raw message