eolivelli commented on a change in pull request #9308:
URL: https://github.com/apache/pulsar/pull/9308#discussion_r598489336
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
##########
@@ -296,16 +299,31 @@ public MetadataStoreExtended
createConfigurationMetadataStore() throws MetadataS
.build());
}
+ @Override
+ public void close() throws PulsarServerException {
+ try {
+ closeAsync().get();
+ } catch (PulsarServerException e) {
+ throw e;
+ } catch (ExecutionException e) {
+ if (e.getCause() instanceof PulsarServerException) {
+ throw (PulsarServerException) e.getCause();
+ } else {
+ throw new PulsarServerException(e.getCause());
+ }
+ } catch (Exception e) {
+ throw new PulsarServerException(e);
+ }
+ }
+
/**
* Close the current pulsar service. All resources are released.
*/
- @Override
- public void close() throws PulsarServerException {
+ public CompletableFuture<Void> closeAsync() throws PulsarServerException {
Review comment:
generally it is a code smell to see a method that returns a
CompletableFuture to throw an exception.
The expectations for the caller is that any error will be reported by the
CompletableFuture.
can we catch all of the possible exceptions and then return a failed
CompletableFuture ?
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]