chia7712 commented on code in PR #20180:
URL: https://github.com/apache/kafka/pull/20180#discussion_r2296245971


##########
server/src/main/java/org/apache/kafka/server/share/session/ShareSessionKey.java:
##########
@@ -21,44 +21,16 @@
 
 import java.util.Objects;
 
-public class ShareSessionKey {
-    private final String groupId;
-    private final Uuid memberId;
-
+public record ShareSessionKey(String groupId, Uuid memberId) {
     public ShareSessionKey(String groupId, Uuid memberId) {
         this.groupId = Objects.requireNonNull(groupId);
         this.memberId = Objects.requireNonNull(memberId);
     }
 
-    public String groupId() {
-        return groupId;
-    }
-
-    public Uuid memberId() {
-        return memberId;
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(groupId, memberId);
-    }
-
-    @Override
-    public boolean equals(final Object obj) {
-        if (this == obj)
-            return true;
-        else if (obj == null || getClass() != obj.getClass())
-            return false;
-        else {
-            ShareSessionKey that = (ShareSessionKey) obj;
-            return groupId.equals(that.groupId) && Objects.equals(memberId, 
that.memberId);
-        }
-    }
-
     public String toString() {

Review Comment:
   this can be removed



##########
server/src/main/java/org/apache/kafka/server/quota/ClientSensors.java:
##########
@@ -25,14 +25,10 @@
 /**
  * Represents the sensors aggregated per client
  */
-public final class ClientSensors {
-    private final Map<String, String> metricTags;
-    private final Sensor quotaSensor;
-    private final Sensor throttleTimeSensor;
-
+public record ClientSensors(Map<String, String> metricTags, Sensor 
quotaSensor, Sensor throttleTimeSensor) {

Review Comment:
   ```java
   /**
    * Represents the sensors aggregated per client
    * @param metricTags         quota metric tags for the client
    * @param quotaSensor        sensor that tracks the quota
    * @param throttleTimeSensor sensor that tracks the throttle time
    */
   public record ClientSensors(Map<String, String> metricTags, Sensor 
quotaSensor, Sensor throttleTimeSensor) {
       public ClientSensors {
           metricTags = new LinkedHashMap<>(metricTags);
           Objects.requireNonNull(quotaSensor);
           Objects.requireNonNull(throttleTimeSensor);
       }
   }
   ```
   This also needs unit test. Especially, the input order must be kept 



##########
server/src/main/java/org/apache/kafka/server/share/session/ShareSessionKey.java:
##########
@@ -21,44 +21,16 @@
 
 import java.util.Objects;
 
-public class ShareSessionKey {
-    private final String groupId;
-    private final Uuid memberId;
-
+public record ShareSessionKey(String groupId, Uuid memberId) {
     public ShareSessionKey(String groupId, Uuid memberId) {

Review Comment:
   ```java
       public ShareSessionKey {
           Objects.requireNonNull(groupId);
           Objects.requireNonNull(memberId);
       }
   ```
   Also, please add unit test for it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to