Skip to content

Commit 8f94bbb

Browse files
committed
Throw a ApiException instead of TopicExistException when create a existed topic.
1 parent 124a440 commit 8f94bbb

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

docs/index.pdf

0 Bytes
Binary file not shown.

src/main/java/org/gnuhpc/bigdata/service/KafkaAdminService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import kafka.common.OffsetAndMetadata;
1212
import kafka.common.Topic;
1313
import kafka.common.TopicAndPartition;
14+
import kafka.common.TopicExistsException;
1415
import kafka.coordinator.GroupOverview;
1516
import kafka.coordinator.GroupTopicPartition;
1617
import kafka.javaapi.OffsetRequest;
@@ -112,6 +113,9 @@ private void init() {
112113
}
113114

114115
public TopicMeta createTopic(TopicDetail topic, String reassignStr) {
116+
if (existTopic(topic.getName())) {
117+
throw new InvalidTopicException("Topic:" + topic.getName() + " already exist.");
118+
}
115119
if (StringUtils.isEmpty(topic.getName())) {
116120
throw new InvalidTopicException("Empty topic name");
117121
}

0 commit comments

Comments
 (0)