World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#3941] fix(common): Fix potential bug of TopicDTO (#3942)
mchadesca9f2201cb7d
diff --git a/common/src/main/java/com/datastrato/gravitino/dto/messaging/TopicDTO.java b/common/src/main/java/com/datastrato/gravitino/dto/messaging/TopicDTO.javaindex f060f3d98f..2be3b9920e 100644--- a/common/src/main/java/com/datastrato/gravitino/dto/messaging/TopicDTO.java+++ b/common/src/main/java/com/datastrato/gravitino/dto/messaging/TopicDTO.java@@ -92,11 +92,12 @@ public class TopicDTO implements Topic {/** A builder for constructing a Topic DTO. */public static class Builder {- private final TopicDTO topic;+ private String name;+ private String comment;+ private Map<String, String> properties;+ private AuditDTO audit;- private Builder() {- topic = new TopicDTO();- }+ private Builder() {}/*** Sets the name of the topic.@@ -105,7 +106,7 @@ public class TopicDTO implements Topic {* @return The builder instance.*/public Builder withName(String name) {- topic.name = name;+ this.name = name;return this;}@@ -116,7 +117,7 @@ public class TopicDTO implements Topic {* @return The builder instance.*/public Builder withComment(String comment) {- topic.comment = comment;+ this.comment = comment;return this;}@@ -127,7 +128,7 @@ public class TopicDTO implements Topic {* @return The builder instance.*/public Builder withProperties(Map<String, String> properties) {- topic.properties = properties;+ this.properties = properties;return this;}@@ -138,13 +139,13 @@ public class TopicDTO implements Topic {* @return The builder instance.*/public Builder withAudit(AuditDTO audit) {- topic.audit = audit;+ this.audit = audit;return this;}/** @return The constructed Topic DTO. */public TopicDTO build() {- return topic;+ return new TopicDTO(name, comment, properties, audit);}}}