codelipenghui commented on a change in pull request #9738:
URL: https://github.com/apache/pulsar/pull/9738#discussion_r584388405



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
##########
@@ -957,8 +957,9 @@ public NamespaceService getNamespaceService() {
         return functionWorkerService;
     }
 
-    public WorkerService getWorkerService() {
-        return functionWorkerService.orElse(null);
+    public WorkerService getWorkerService() throws 
UnsupportedOperationException {
+        return functionWorkerService.orElseThrow(() -> new 
UnsupportedOperationException("Pulsar Function Worker is not " +
+                "enabled, probably functionsWorkerEnabled is set to false"));

Review comment:
       I think you can use `getWorkerServiceOpt()` to check if the 
`workerService` is present? Since the `workerService` might be used in multiple 
places if we throw an exception here, this means all the places will throw an 
exception, this is not necessarily the right choice for all operations. So my 
suggestion is to let the caller to decide the behavior by checking the 
`getWorkerServiceOpt()`. 




----------------------------------------------------------------
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]


Reply via email to