Skip to content

Commit

Permalink
[improve][broker] Removing webURL check null (#21043)
Browse files Browse the repository at this point in the history
### Motivation

Removing `webUrl` null-check, because it couldn't be null.

### Modifications

Removing `webUrl` null-check
  • Loading branch information
AnonHxy authored Aug 23, 2023
1 parent c1b0454 commit e951cd0
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -759,15 +759,13 @@ protected CompletableFuture<Void> validateTopicOwnershipAsync(TopicName topicNam
.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();
Expand Down

0 comments on commit e951cd0

Please sign in to comment.