cbornet commented on code in PR #20658:
URL: https://github.com/apache/pulsar/pull/20658#discussion_r1245513039
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java:
##########
@@ -248,44 +248,43 @@ private CompletableFuture<NamespaceBundle>
getFullBundleAsync(NamespaceName fqnn
/**
* Return the URL of the broker who's owning a particular service unit in
asynchronous way.
- *
+ * <p>
* If the service unit is not owned, return a CompletableFuture with empty
optional.
*/
public CompletableFuture<Optional<URL>>
getWebServiceUrlAsync(ServiceUnitId suName, LookupOptions options) {
- if (suName instanceof TopicName) {
- TopicName name = (TopicName) suName;
+ if (suName instanceof TopicName name) {
if (LOG.isDebugEnabled()) {
LOG.debug("Getting web service URL of topic: {} - options:
{}", name, options);
}
return getBundleAsync(name)
.thenCompose(namespaceBundle ->
- internalGetWebServiceUrl(Optional.of(name),
namespaceBundle, options));
+ internalGetWebServiceUrl(name, namespaceBundle,
options));
}
- if (suName instanceof NamespaceName) {
- return getFullBundleAsync((NamespaceName) suName)
+ if (suName instanceof NamespaceName namespaceName) {
+ return getFullBundleAsync(namespaceName)
.thenCompose(namespaceBundle ->
- internalGetWebServiceUrl(Optional.empty(),
namespaceBundle, options));
+ internalGetWebServiceUrl(null, namespaceBundle,
options));
}
- if (suName instanceof NamespaceBundle) {
- return internalGetWebServiceUrl(Optional.empty(),
(NamespaceBundle) suName, options);
+ if (suName instanceof NamespaceBundle namespaceBundle) {
+ return internalGetWebServiceUrl(null, namespaceBundle, options);
}
throw new IllegalArgumentException("Unrecognized class of
NamespaceBundle: " + suName.getClass().getName());
}
/**
* Return the URL of the broker who's owning a particular service unit.
- *
+ * <p>
* If the service unit is not owned, return an empty optional
*/
public Optional<URL> getWebServiceUrl(ServiceUnitId suName, LookupOptions
options) throws Exception {
return getWebServiceUrlAsync(suName, options)
.get(pulsar.getConfiguration().getMetadataStoreOperationTimeoutSeconds(),
SECONDS);
}
- private CompletableFuture<Optional<URL>>
internalGetWebServiceUrl(Optional<ServiceUnitId> topic,
+ private CompletableFuture<Optional<URL>>
internalGetWebServiceUrl(ServiceUnitId topic,
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]