kafka-jira mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KAFKA-4920) Stamped should implement equals
Date Mon, 26 Feb 2018 22:38:00 GMT

    [ https://issues.apache.org/jira/browse/KAFKA-4920?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16377724#comment-16377724
] 

ASF GitHub Bot commented on KAFKA-4920:
---------------------------------------

guozhangwang closed pull request #4622: KAFKA-4920: Stamped implements equals
URL: https://github.com/apache/kafka/pull/4622
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/gradle/findbugs-exclude.xml b/gradle/findbugs-exclude.xml
index 33702056d83..662864c8c73 100644
--- a/gradle/findbugs-exclude.xml
+++ b/gradle/findbugs-exclude.xml
@@ -241,12 +241,6 @@ For a detailed description of findbugs bug categories, see http://findbugs.sourc
         <Bug pattern="IS2_INCONSISTENT_SYNC"/>
     </Match>
 
-    <Match>
-        <!-- Suppress warnings about implementing compareTo but not equals. -->
-        <Class name="org.apache.kafka.streams.processor.internals.Stamped"/>
-        <Bug pattern="EQ_COMPARETO_USE_OBJECT_EQUALS"/>
-    </Match>
-
     <Match>
         <!-- TODO: fix this (see KAFKA-4996) -->
         <Or>
diff --git a/streams/src/main/java/org/apache/kafka/streams/processor/internals/Stamped.java
b/streams/src/main/java/org/apache/kafka/streams/processor/internals/Stamped.java
index 4965238e856..4452a9b9a92 100644
--- a/streams/src/main/java/org/apache/kafka/streams/processor/internals/Stamped.java
+++ b/streams/src/main/java/org/apache/kafka/streams/processor/internals/Stamped.java
@@ -34,4 +34,19 @@ public int compareTo(Object other) {
         else if (timestamp > otherTimestamp) return 1;
         return 0;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        // we do not compare values for this stamped object
+        return this.compareTo(o) == 0;
+    }
+
+    @Override
+    public int hashCode() {
+        // we do not use values for this object's hashcode
+        return (int) (timestamp ^ (timestamp >>> 32));
+    }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Stamped should implement equals
> -------------------------------
>
>                 Key: KAFKA-4920
>                 URL: https://issues.apache.org/jira/browse/KAFKA-4920
>             Project: Kafka
>          Issue Type: Improvement
>          Components: streams
>            Reporter: Marc Juchli
>            Priority: Minor
>
> We ran FundBug, which resulted in the "Bad practice warning": 
> Bug type EQ_COMPARETO_USE_OBJECT_EQUALS (click for details) 
> In class org.apache.kafka.streams.processor.internals.Stamped
> In method org.apache.kafka.streams.processor.internals.Stamped.compareTo(Object)
> At Stamped.java:[lines 31-35]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message