KAFKA-19295: Remove AsyncKafkaConsumer event ID generation (#19915)
CI / build (push) Waiting to run Details

Remove the event IDs from the ApplicationEvent and BackgroundEvent as it
serves no functional purpose other than uniquely identifying events in
the logs.

Reviewers: Andrew Schofield <aschofield@confluent.io>
This commit is contained in:
Kirk True 2025-06-07 05:08:22 -07:00 committed by GitHub
parent c4a769bc8b
commit 861eeb859d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 52 deletions

View File

@ -18,7 +18,6 @@ package org.apache.kafka.clients.consumer.internals.events;
import org.apache.kafka.clients.consumer.internals.AsyncKafkaConsumer; import org.apache.kafka.clients.consumer.internals.AsyncKafkaConsumer;
import org.apache.kafka.clients.consumer.internals.ShareConsumerImpl; import org.apache.kafka.clients.consumer.internals.ShareConsumerImpl;
import org.apache.kafka.common.Uuid;
import java.util.Objects; import java.util.Objects;
@ -48,12 +47,6 @@ public abstract class ApplicationEvent {
private final Type type; private final Type type;
/**
* This identifies a particular event. It is used to disambiguate events via {@link #hashCode()} and
* {@link #equals(Object)} and can be used in log messages when debugging.
*/
private final Uuid id;
/** /**
* The time in milliseconds when this event was enqueued. * The time in milliseconds when this event was enqueued.
* This field can be changed after the event is created, so it should not be used in hashCode or equals. * This field can be changed after the event is created, so it should not be used in hashCode or equals.
@ -62,17 +55,12 @@ public abstract class ApplicationEvent {
protected ApplicationEvent(Type type) { protected ApplicationEvent(Type type) {
this.type = Objects.requireNonNull(type); this.type = Objects.requireNonNull(type);
this.id = Uuid.randomUuid();
} }
public Type type() { public Type type() {
return type; return type;
} }
public Uuid id() {
return id;
}
public void setEnqueuedMs(long enqueuedMs) { public void setEnqueuedMs(long enqueuedMs) {
this.enqueuedMs = enqueuedMs; this.enqueuedMs = enqueuedMs;
} }
@ -81,21 +69,8 @@ public abstract class ApplicationEvent {
return enqueuedMs; return enqueuedMs;
} }
@Override
public final boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ApplicationEvent that = (ApplicationEvent) o;
return type == that.type && id.equals(that.id);
}
@Override
public final int hashCode() {
return Objects.hash(type, id);
}
protected String toStringBase() { protected String toStringBase() {
return "type=" + type + ", id=" + id + ", enqueuedMs=" + enqueuedMs; return "type=" + type + ", enqueuedMs=" + enqueuedMs;
} }
@Override @Override

View File

@ -17,7 +17,6 @@
package org.apache.kafka.clients.consumer.internals.events; package org.apache.kafka.clients.consumer.internals.events;
import org.apache.kafka.clients.consumer.internals.ConsumerNetworkThread; import org.apache.kafka.clients.consumer.internals.ConsumerNetworkThread;
import org.apache.kafka.common.Uuid;
import java.util.Objects; import java.util.Objects;
@ -37,12 +36,6 @@ public abstract class BackgroundEvent {
private final Type type; private final Type type;
/**
* This identifies a particular event. It is used to disambiguate events via {@link #hashCode()} and
* {@link #equals(Object)} and can be used in log messages when debugging.
*/
private final Uuid id;
/** /**
* The time in milliseconds when this event was enqueued. * The time in milliseconds when this event was enqueued.
* This field can be changed after the event is created, so it should not be used in hashCode or equals. * This field can be changed after the event is created, so it should not be used in hashCode or equals.
@ -51,17 +44,12 @@ public abstract class BackgroundEvent {
protected BackgroundEvent(Type type) { protected BackgroundEvent(Type type) {
this.type = Objects.requireNonNull(type); this.type = Objects.requireNonNull(type);
this.id = Uuid.randomUuid();
} }
public Type type() { public Type type() {
return type; return type;
} }
public Uuid id() {
return id;
}
public void setEnqueuedMs(long enqueuedMs) { public void setEnqueuedMs(long enqueuedMs) {
this.enqueuedMs = enqueuedMs; this.enqueuedMs = enqueuedMs;
} }
@ -70,21 +58,8 @@ public abstract class BackgroundEvent {
return enqueuedMs; return enqueuedMs;
} }
@Override
public final boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BackgroundEvent that = (BackgroundEvent) o;
return type == that.type && id.equals(that.id);
}
@Override
public final int hashCode() {
return Objects.hash(type, id);
}
protected String toStringBase() { protected String toStringBase() {
return "type=" + type + ", id=" + id + ", enqueuedMs=" + enqueuedMs; return "type=" + type + ", enqueuedMs=" + enqueuedMs;
} }
@Override @Override