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-4921) AssignedPartition should implement equals
Date Mon, 26 Feb 2018 18:41:00 GMT

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

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

guozhangwang closed pull request #2712: KAFKA-4921: AssignedPartition implements equals
URL: https://github.com/apache/kafka/pull/2712
 
 
   

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/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamPartitionAssignor.java
b/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamPartitionAssignor.java
index 859d6611228..42141813580 100644
--- a/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamPartitionAssignor.java
+++ b/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamPartitionAssignor.java
@@ -74,6 +74,25 @@
         public int compareTo(final AssignedPartition that) {
             return PARTITION_COMPARATOR.compare(this.partition, that.partition);
         }
+
+        @Override
+        public boolean equals(Object o) {
+            if (this == o) return true;
+            if (o == null || getClass() != o.getClass()) return false;
+
+            AssignedPartition that = (AssignedPartition) o;
+
+            if (taskId != null ? !taskId.equals(that.taskId) : that.taskId != null) return
false;
+            return partition != null ? partition.equals(that.partition) : that.partition
== null;
+
+        }
+
+        @Override
+        public int hashCode() {
+            int result = taskId != null ? taskId.hashCode() : 0;
+            result = 31 * result + (partition != null ? partition.hashCode() : 0);
+            return result;
+        }
     }
 
     private static class ClientMetadata {


 

----------------------------------------------------------------
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


> AssignedPartition should implement equals
> -----------------------------------------
>
>                 Key: KAFKA-4921
>                 URL: https://issues.apache.org/jira/browse/KAFKA-4921
>             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.StreamPartitionAssignor$AssignedPartition
> In method org.apache.kafka.streams.processor.internals.StreamPartitionAssignor$AssignedPartition.compareTo(StreamPartitionAssignor$AssignedPartition)
> At StreamPartitionAssignor.java:[line 75]



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

Mime
View raw message