Skip to content

Commit 7a959cb

Browse files
authored
Bump Pulsar to 5.0.0-M1-SNAPSHOT (#1848)
1 parent 773cb47 commit 7a959cb

2 files changed

Lines changed: 10 additions & 15 deletions

File tree

amqp-impl/src/main/java/io/streamnative/pulsar/handlers/amqp/admin/impl/BaseResources.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import io.streamnative.pulsar.handlers.amqp.QueueService;
2121
import io.streamnative.pulsar.handlers.amqp.admin.model.VhostBean;
2222
import java.net.URI;
23-
import java.net.URL;
2423
import java.util.ArrayList;
2524
import java.util.List;
2625
import java.util.concurrent.CompletableFuture;
@@ -143,40 +142,36 @@ private PulsarService pulsar() {
143142
return aop().getBrokerService().getPulsar();
144143
}
145144

146-
public boolean isRequestHttps() {
147-
return "https".equalsIgnoreCase(httpRequest.getScheme());
148-
}
149-
150145
protected CompletableFuture<Void> validateTopicOwnershipAsync(TopicName topicName, boolean authoritative) {
151146
NamespaceService nsService = pulsar().getNamespaceService();
152147

153148
LookupOptions options = LookupOptions.builder()
154149
.authoritative(authoritative)
155-
.requestHttps(isRequestHttps())
156150
.readOnly(false)
157151
.loadTopicsInBundle(false)
158152
.build();
159153

160-
return nsService.getWebServiceUrlAsync(topicName, options)
161-
.thenApply(webUrl -> {
154+
return nsService.getLookupResultForWebRequestAsync(topicName, options)
155+
.thenApply(lookupResult -> {
162156
// Ensure we get a url
163-
if (webUrl == null || !webUrl.isPresent()) {
164-
log.info("Unable to get web service url");
157+
if (lookupResult.isEmpty()) {
158+
log.warn("Unable to get lookup result for topic: {}, authoritative: {}",
159+
topicName, authoritative);
165160
throw new RestException(Response.Status.PRECONDITION_FAILED,
166161
"Failed to find ownership for topic:" + topicName);
167162
}
168-
return webUrl.get();
163+
return lookupResult.get();
169164
}).thenCompose(webUrl -> nsService.isServiceUnitOwnedAsync(topicName)
170165
.thenApply(isTopicOwned -> Pair.of(webUrl, isTopicOwned))
171166
).thenAccept(pair -> {
172-
URL webUrl = pair.getLeft();
167+
URI webUri = pair.getLeft().toLookupRedirectUri(uri.getRequestUri());
173168
boolean isTopicOwned = pair.getRight();
174169

175170
if (!isTopicOwned) {
176171
boolean newAuthoritative = isLeaderBroker(pulsar());
177172
// Replace the host and port of the current request and redirect
178173
URI redirect = UriBuilder.fromUri(uri.getRequestUri())
179-
.host(webUrl.getHost())
174+
.host(webUri.getHost())
180175
.port(aop().getAmqpConfig().getAmqpAdminPort())
181176
.replaceQueryParam("authoritative", newAuthoritative)
182177
.build();

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
<project.compiler.release>${maven.compiler.target}</project.compiler.release>
4141

4242
<!-- dependencies -->
43-
<pulsar.version>4.2.0-SNAPSHOT</pulsar.version>
43+
<pulsar.version>5.0.0-M1-SNAPSHOT</pulsar.version>
44+
<sn.bom.version>5.0.0-M1-SNAPSHOT</sn.bom.version>
4445
<qpid-protocol-plugin.version>8.0.0</qpid-protocol-plugin.version>
4546
<rabbitmq.version>5.8.0</rabbitmq.version>
46-
<sn.bom.version>4.2.0-SNAPSHOT</sn.bom.version>
4747
<opentelemetry.version>1.56.0</opentelemetry.version>
4848

4949
<!-- test dependencies -->

0 commit comments

Comments
 (0)