chia7712 commented on code in PR #24320:
URL: https://github.com/apache/kafka/pull/24320#discussion_r4680686965
##########
metadata/src/main/java/org/apache/kafka/image/TopicImage.java:
##########
@@ -27,29 +28,108 @@
import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Optional;
/**
* Represents a topic in the metadata image.
*
* This class is thread-safe.
*/
-public record TopicImage(String name, Uuid id, Map<Integer,
PartitionRegistration> partitions) {
- public TopicImage {
- partitions = Collections.unmodifiableMap(partitions);
+public final class TopicImage {
Review Comment:
It seems to me removing the record class is a kind of regression. Could we
keep the record by declaring the component as `Optional<Mirror>`?
```java
public record TopicImage(String name,
Uuid id,
Optional<Mirror> mirror,
Map<Integer, PartitionRegistration> partitions) {
public TopicImage {
Objects.requireNonNull(mirror);
partitions = Collections.unmodifiableMap(partitions);
}
public TopicImage(String name, Uuid id, Map<Integer,
PartitionRegistration> partitions) {
this(name, id, Optional.empty(), partitions);
}
}
```
--
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]