Skip to content

Commit 401fb05

Browse files
authored
[fix] [broker] delete topic failed if disabled system topic (apache#19735)
Motivation: After PR apache#18823, The cmd delete topic will fail if disabled the feature system topic. Modifications: do not delete the system policy if disabled the feature system topic
1 parent cdeef00 commit 401fb05

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,8 @@ private CompletableFuture<Void> delete(boolean failIfHasSubscriptions,
12461246

12471247
deleteTopicAuthenticationFuture.thenCompose(ignore -> deleteSchema())
12481248
.thenCompose(ignore -> {
1249-
if (!SystemTopicNames.isTopicPoliciesSystemTopic(topic)) {
1249+
if (!SystemTopicNames.isTopicPoliciesSystemTopic(topic)
1250+
&& brokerService.getPulsar().getConfiguration().isSystemTopicEnabled()) {
12501251
return deleteTopicPolicies();
12511252
} else {
12521253
return CompletableFuture.completedFuture(null);
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.pulsar.client.impl;
20+
21+
import java.util.UUID;
22+
import lombok.extern.slf4j.Slf4j;
23+
import org.apache.pulsar.client.api.ProducerConsumerBase;
24+
import org.testng.annotations.AfterMethod;
25+
import org.testng.annotations.BeforeMethod;
26+
import org.testng.annotations.Test;
27+
28+
@Slf4j
29+
@Test(groups = "broker")
30+
public class DisabledSystemTopicTest extends ProducerConsumerBase {
31+
32+
@Override
33+
@BeforeMethod
34+
public void setup() throws Exception {
35+
super.internalSetup();
36+
super.producerBaseSetup();
37+
}
38+
39+
@Override
40+
@AfterMethod(alwaysRun = true)
41+
public void cleanup() throws Exception {
42+
super.internalCleanup();
43+
}
44+
45+
protected void doInitConf() throws Exception {
46+
super.doInitConf();
47+
conf.setTransactionCoordinatorEnabled(false);
48+
conf.setSystemTopicEnabled(false);
49+
}
50+
51+
@Test
52+
public void testDeleteTopic() throws Exception {
53+
String topicName = "persistent://my-property/my-ns/tp_" + UUID.randomUUID().toString();
54+
55+
admin.topics().createNonPartitionedTopic(topicName);
56+
admin.topics().delete(topicName, false);
57+
58+
admin.topics().createPartitionedTopic(topicName, 3);
59+
admin.topics().deletePartitionedTopic(topicName);
60+
}
61+
}

0 commit comments

Comments
 (0)