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


##########
core/src/main/java/kafka/server/QuotaFactory.java:
##########
@@ -51,61 +51,14 @@ public void record(long value) {
         }
     };
 
-    public static class QuotaManagers {
-        private final ClientQuotaManager fetch;
-        private final ClientQuotaManager produce;
-        private final ClientRequestQuotaManager request;
-        private final ControllerMutationQuotaManager controllerMutation;
-        private final ReplicationQuotaManager leader;
-        private final ReplicationQuotaManager follower;
-        private final ReplicationQuotaManager alterLogDirs;
-        private final Optional<Plugin<ClientQuotaCallback>> 
clientQuotaCallbackPlugin;
-
-        public QuotaManagers(ClientQuotaManager fetch, ClientQuotaManager 
produce, ClientRequestQuotaManager request,
-                             ControllerMutationQuotaManager 
controllerMutation, ReplicationQuotaManager leader,
-                             ReplicationQuotaManager follower, 
ReplicationQuotaManager alterLogDirs,
-                             Optional<Plugin<ClientQuotaCallback>> 
clientQuotaCallbackPlugin) {
-            this.fetch = fetch;
-            this.produce = produce;
-            this.request = request;
-            this.controllerMutation = controllerMutation;
-            this.leader = leader;
-            this.follower = follower;
-            this.alterLogDirs = alterLogDirs;
-            this.clientQuotaCallbackPlugin = clientQuotaCallbackPlugin;
-        }
-
-        public ClientQuotaManager fetch() {
-            return fetch;
-        }
-
-        public ClientQuotaManager produce() {
-            return produce;
-        }
-
-        public ClientRequestQuotaManager request() {
-            return request;
-        }
-
-        public ControllerMutationQuotaManager controllerMutation() {
-            return controllerMutation;
-        }
-
-        public ReplicationQuotaManager leader() {
-            return leader;
-        }
-
-        public ReplicationQuotaManager follower() {
-            return follower;
-        }
-
-        public ReplicationQuotaManager alterLogDirs() {
-            return alterLogDirs;
-        }
-
-        public Optional<Plugin<ClientQuotaCallback>> 
clientQuotaCallbackPlugin() {
-            return clientQuotaCallbackPlugin;
-        }
+    public record QuotaManagers(ClientQuotaManager fetch,

Review Comment:
   I prefer not to use `record`, as mutable fields can lead to undefined 
behavior in `equals` and `hashCode`



##########
core/src/main/java/kafka/server/QuotaFactory.java:
##########
@@ -51,61 +51,14 @@ public void record(long value) {
         }
     };
 
-    public static class QuotaManagers {
-        private final ClientQuotaManager fetch;
-        private final ClientQuotaManager produce;
-        private final ClientRequestQuotaManager request;
-        private final ControllerMutationQuotaManager controllerMutation;
-        private final ReplicationQuotaManager leader;
-        private final ReplicationQuotaManager follower;
-        private final ReplicationQuotaManager alterLogDirs;
-        private final Optional<Plugin<ClientQuotaCallback>> 
clientQuotaCallbackPlugin;
-
-        public QuotaManagers(ClientQuotaManager fetch, ClientQuotaManager 
produce, ClientRequestQuotaManager request,
-                             ControllerMutationQuotaManager 
controllerMutation, ReplicationQuotaManager leader,
-                             ReplicationQuotaManager follower, 
ReplicationQuotaManager alterLogDirs,
-                             Optional<Plugin<ClientQuotaCallback>> 
clientQuotaCallbackPlugin) {
-            this.fetch = fetch;
-            this.produce = produce;
-            this.request = request;
-            this.controllerMutation = controllerMutation;
-            this.leader = leader;
-            this.follower = follower;
-            this.alterLogDirs = alterLogDirs;
-            this.clientQuotaCallbackPlugin = clientQuotaCallbackPlugin;
-        }
-
-        public ClientQuotaManager fetch() {
-            return fetch;
-        }
-
-        public ClientQuotaManager produce() {
-            return produce;
-        }
-
-        public ClientRequestQuotaManager request() {
-            return request;
-        }
-
-        public ControllerMutationQuotaManager controllerMutation() {
-            return controllerMutation;
-        }
-
-        public ReplicationQuotaManager leader() {
-            return leader;
-        }
-
-        public ReplicationQuotaManager follower() {
-            return follower;
-        }
-
-        public ReplicationQuotaManager alterLogDirs() {
-            return alterLogDirs;
-        }
-
-        public Optional<Plugin<ClientQuotaCallback>> 
clientQuotaCallbackPlugin() {
-            return clientQuotaCallbackPlugin;
-        }
+    public record QuotaManagers(ClientQuotaManager fetch,

Review Comment:
   However, the rule seems hard to enforce, as there are existing record 
classes in the codebase that violate immutability 



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