mumrah commented on code in PR #17633:
URL: https://github.com/apache/kafka/pull/17633#discussion_r1822929049


##########
metadata/src/main/java/org/apache/kafka/controller/PeriodicTaskControlManager.java:
##########
@@ -206,7 +206,7 @@ private void reschedule(PeriodicTask task, boolean 
immediate, boolean error) {
             long nextDelayTimeNs = nextDelayTimeNs(task, immediate, error);
             long nextRunTimeNs = time.nanoseconds() + nextDelayTimeNs;
             log.trace("rescheduling {} in {} ns (immediate = {}, error = {})",
-                    task.name(), nextDelayTimeNs, immediate);
+                    task.name(), nextDelayTimeNs, immediate, error);

Review Comment:
   nice find :) 



##########
metadata/src/main/java/org/apache/kafka/metadata/util/SnapshotFileReader.java:
##########
@@ -130,17 +131,15 @@ private void handleControlBatch(FileChannelRecordBatch 
batch) {
             try {
                 short typeId = ControlRecordType.parseTypeId(record.key());
                 ControlRecordType type = ControlRecordType.fromTypeId(typeId);
-                switch (type) {
-                    case LEADER_CHANGE:
-                        LeaderChangeMessage message = new 
LeaderChangeMessage();
-                        message.read(new ByteBufferAccessor(record.value()), 
(short) 0);
-                        listener.handleLeaderChange(new LeaderAndEpoch(
+                if (Objects.requireNonNull(type) == 
ControlRecordType.LEADER_CHANGE) {

Review Comment:
   Since ControlRecordType.fromTypeId always returns a non-null, we can just do 
`if(type == ControlRecordType.LEADER_CHANGE)`. Theoretically, using 
`Objects.requireNonNull(type)` changes the behavior by throwing instead of just 
logging an error.
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to