kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ewe...@apache.org
Subject kafka git commit: KAFKA-4924: Fix Kafka Connect API findbugs warnings
Date Tue, 21 Mar 2017 23:48:03 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 6f7780cf1 -> a7e3679d2


KAFKA-4924: Fix Kafka Connect API findbugs warnings

Author: Colin P. Mccabe <cmccabe@confluent.io>

Reviewers: Ewen Cheslack-Postava <ewen@confluent.io>

Closes #2715 from cmccabe/KAFKA-4924


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/a7e3679d
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/a7e3679d
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/a7e3679d

Branch: refs/heads/trunk
Commit: a7e3679d22504b0808e970ac9c481a3ee62f9243
Parents: 6f7780c
Author: Colin P. Mccabe <cmccabe@confluent.io>
Authored: Tue Mar 21 16:48:26 2017 -0700
Committer: Ewen Cheslack-Postava <me@ewencp.org>
Committed: Tue Mar 21 16:48:44 2017 -0700

----------------------------------------------------------------------
 .../org/apache/kafka/connect/data/Decimal.java  |  2 +-
 .../kafka/connect/json/JsonConverter.java       |  3 +-
 gradle/findbugs-exclude.xml                     | 30 ++++++++++++++++++++
 3 files changed, 33 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/a7e3679d/connect/api/src/main/java/org/apache/kafka/connect/data/Decimal.java
----------------------------------------------------------------------
diff --git a/connect/api/src/main/java/org/apache/kafka/connect/data/Decimal.java b/connect/api/src/main/java/org/apache/kafka/connect/data/Decimal.java
index bf6fb3a..2bf87f1 100644
--- a/connect/api/src/main/java/org/apache/kafka/connect/data/Decimal.java
+++ b/connect/api/src/main/java/org/apache/kafka/connect/data/Decimal.java
@@ -50,7 +50,7 @@ public class Decimal {
     public static SchemaBuilder builder(int scale) {
         return SchemaBuilder.bytes()
                 .name(LOGICAL_NAME)
-                .parameter(SCALE_FIELD, ((Integer) scale).toString())
+                .parameter(SCALE_FIELD, Integer.toString(scale))
                 .version(1);
     }
 

http://git-wip-us.apache.org/repos/asf/kafka/blob/a7e3679d/connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java
----------------------------------------------------------------------
diff --git a/connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java b/connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java
index d9b4f32..a7b37f1 100644
--- a/connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java
+++ b/connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java
@@ -655,7 +655,8 @@ public class JsonConverter implements Converter {
 
             throw new DataException("Couldn't convert " + value + " to JSON.");
         } catch (ClassCastException e) {
-            throw new DataException("Invalid type for " + schema.type() + ": " + value.getClass());
+            String schemaTypeStr = (schema != null) ? schema.type().toString() : "unknown
schema";
+            throw new DataException("Invalid type for " + schemaTypeStr + ": " + value.getClass());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/kafka/blob/a7e3679d/gradle/findbugs-exclude.xml
----------------------------------------------------------------------
diff --git a/gradle/findbugs-exclude.xml b/gradle/findbugs-exclude.xml
index 90eca5a..2515a4a 100644
--- a/gradle/findbugs-exclude.xml
+++ b/gradle/findbugs-exclude.xml
@@ -25,4 +25,34 @@
     <Match>
         <Bug code="EI,EI2,MS"/>
     </Match>
+
+    <Match>
+        <!-- Suppress a warning about some static initializers in Schema using instances
of a
+             subclass. -->
+        <Or>
+            <Class name="org.apache.kafka.connect.data.Schema"/>
+            <Class name="org.apache.kafka.connect.data.SchemaBuilder"/>
+        </Or>
+        <Bug pattern="IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION"/>
+    </Match>
+
+    <Match>
+        <!-- Suppress warnings about unread protected fields in some public classes.
+             Although these are not read in Kafka Connect code, they are part of the API.
-->
+        <Or>
+            <Class name="org.apache.kafka.connect.connector.Connector"/>
+            <Class name="org.apache.kafka.connect.sink.SinkTask"/>
+            <Class name="org.apache.kafka.connect.source.SourceTask"/>
+        </Or>
+        <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
+    </Match>
+
+    <Match>
+        <!-- Suppress warnings about converting an integer number of
+             milliseconds to a java.util.Date object.  We do this intentionally in
+             org.apache.kafka.connect.data.Time. -->
+        <Class name="org.apache.kafka.connect.data.Time"/>
+        <Method name="toLogical"/>
+        <Bug pattern="ICAST_INT_2_LONG_AS_INSTANT"/>
+    </Match>
 </FindBugsFilter>


Mime
View raw message