This is an automated email from the ASF dual-hosted git repository.

houxiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new e951cd05268 [improve][broker] Removing webURL check null (#21043)
e951cd05268 is described below

commit e951cd05268bd4e01fd1ab161fa2df65d219c8fc
Author: houxiaoyu <[email protected]>
AuthorDate: Wed Aug 23 15:16:06 2023 +0800

    [improve][broker] Removing webURL check null (#21043)
    
    ### Motivation
    
    Removing `webUrl` null-check, because it couldn't be null.
    
    ### Modifications
    
    Removing `webUrl` null-check
---
 .../org/apache/pulsar/broker/web/PulsarWebResource.java  | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
index fa121b8eb4d..e65ef50c72a 100644
--- 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
+++ 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
@@ -759,15 +759,13 @@ public abstract class PulsarWebResource {
                 .build();
 
         return nsService.getWebServiceUrlAsync(topicName, options)
-                .thenApply(webUrl -> {
-                    // Ensure we get a url
-                    if (webUrl == null || !webUrl.isPresent()) {
-                        log.info("Unable to get web service url");
-                        throw new RestException(Status.PRECONDITION_FAILED,
-                                "Failed to find ownership for topic:" + 
topicName);
-                    }
-                    return webUrl.get();
-                }).thenCompose(webUrl -> 
nsService.isServiceUnitOwnedAsync(topicName)
+                .thenApply(webUrl ->
+                        webUrl.orElseThrow(() -> {
+                            log.info("Unable to get web service url");
+                            throw new RestException(Status.PRECONDITION_FAILED,
+                                    "Failed to find ownership for topic:" + 
topicName);
+                        })
+                ).thenCompose(webUrl -> 
nsService.isServiceUnitOwnedAsync(topicName)
                         .thenApply(isTopicOwned -> Pair.of(webUrl, 
isTopicOwned))
                 ).thenAccept(pair -> {
                     URL webUrl = pair.getLeft();

Reply via email to