mirror of https://github.com/apache/kafka.git
MINOR: Fix incorrect Java equals comparison of Uuid by reference (#15707)
Reviewers: Justine Olshan <jolshan@confluent.io>, Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
parent
e02ffd852f
commit
c034cf2953
|
@ -1702,7 +1702,7 @@ public class KafkaAdminClient extends AdminClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean topicIdIsUnrepresentable(Uuid topicId) {
|
private static boolean topicIdIsUnrepresentable(Uuid topicId) {
|
||||||
return topicId == null || topicId == Uuid.ZERO_UUID;
|
return topicId == null || topicId.equals(Uuid.ZERO_UUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for testing
|
// for testing
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class MetadataResponse extends AbstractResponse {
|
||||||
public Map<Uuid, Errors> errorsByTopicId() {
|
public Map<Uuid, Errors> errorsByTopicId() {
|
||||||
Map<Uuid, Errors> errors = new HashMap<>();
|
Map<Uuid, Errors> errors = new HashMap<>();
|
||||||
for (MetadataResponseTopic metadata : data.topics()) {
|
for (MetadataResponseTopic metadata : data.topics()) {
|
||||||
if (metadata.topicId() == Uuid.ZERO_UUID) {
|
if (metadata.topicId().equals(Uuid.ZERO_UUID)) {
|
||||||
throw new IllegalStateException("Use errors() when managing topic using topic name");
|
throw new IllegalStateException("Use errors() when managing topic using topic name");
|
||||||
}
|
}
|
||||||
if (metadata.errorCode() != Errors.NONE.code())
|
if (metadata.errorCode() != Errors.NONE.code())
|
||||||
|
|
|
@ -133,7 +133,7 @@ public class ClientTelemetryUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Uuid validateClientInstanceId(Uuid clientInstanceId) {
|
public static Uuid validateClientInstanceId(Uuid clientInstanceId) {
|
||||||
if (clientInstanceId == null || clientInstanceId == Uuid.ZERO_UUID) {
|
if (clientInstanceId == null || clientInstanceId.equals(Uuid.ZERO_UUID)) {
|
||||||
throw new IllegalArgumentException("clientInstanceId is not valid");
|
throw new IllegalArgumentException("clientInstanceId is not valid");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,9 +63,9 @@ public class PartitionMetadataFile {
|
||||||
public void record(Uuid topicId) {
|
public void record(Uuid topicId) {
|
||||||
// Topic IDs should not differ, but we defensively check here to fail earlier in the case that the IDs somehow differ.
|
// Topic IDs should not differ, but we defensively check here to fail earlier in the case that the IDs somehow differ.
|
||||||
dirtyTopicIdOpt.ifPresent(dirtyTopicId -> {
|
dirtyTopicIdOpt.ifPresent(dirtyTopicId -> {
|
||||||
if (dirtyTopicId != topicId) {
|
if (!dirtyTopicId.equals(topicId)) {
|
||||||
throw new InconsistentTopicIdException("Tried to record topic ID $topicId to file " +
|
throw new InconsistentTopicIdException("Tried to record topic ID " + topicId + " to file " +
|
||||||
"but had already recorded $dirtyTopicId");
|
"but had already recorded " + dirtyTopicId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dirtyTopicIdOpt = Optional.of(topicId);
|
dirtyTopicIdOpt = Optional.of(topicId);
|
||||||
|
|
|
@ -296,7 +296,7 @@ public abstract class TopicCommand {
|
||||||
.map(ce -> ce.name() + "=" + ce.value())
|
.map(ce -> ce.name() + "=" + ce.value())
|
||||||
.collect(Collectors.joining(","));
|
.collect(Collectors.joining(","));
|
||||||
System.out.print("Topic: " + topic);
|
System.out.print("Topic: " + topic);
|
||||||
if (topicId != Uuid.ZERO_UUID)
|
if (!topicId.equals(Uuid.ZERO_UUID))
|
||||||
System.out.print("\tTopicId: " + topicId);
|
System.out.print("\tTopicId: " + topicId);
|
||||||
System.out.print("\tPartitionCount: " + numPartitions);
|
System.out.print("\tPartitionCount: " + numPartitions);
|
||||||
System.out.print("\tReplicationFactor: " + replicationFactor);
|
System.out.print("\tReplicationFactor: " + replicationFactor);
|
||||||
|
@ -539,7 +539,7 @@ public abstract class TopicCommand {
|
||||||
public void describeTopic(TopicCommandOptions opts) throws ExecutionException, InterruptedException {
|
public void describeTopic(TopicCommandOptions opts) throws ExecutionException, InterruptedException {
|
||||||
// If topicId is provided and not zero, will use topicId regardless of topic name
|
// If topicId is provided and not zero, will use topicId regardless of topic name
|
||||||
Optional<Uuid> inputTopicId = opts.topicId()
|
Optional<Uuid> inputTopicId = opts.topicId()
|
||||||
.map(Uuid::fromString).filter(uuid -> uuid != Uuid.ZERO_UUID);
|
.map(Uuid::fromString).filter(uuid -> !uuid.equals(Uuid.ZERO_UUID));
|
||||||
Boolean useTopicId = inputTopicId.isPresent();
|
Boolean useTopicId = inputTopicId.isPresent();
|
||||||
|
|
||||||
List<Uuid> topicIds;
|
List<Uuid> topicIds;
|
||||||
|
|
Loading…
Reference in New Issue