jerrypeng commented on a change in pull request #7255: URL: https://github.com/apache/pulsar/pull/7255#discussion_r440380986
########## File path: pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/FunctionMetaDataTopicTailer.java ########## @@ -63,12 +65,22 @@ public void start() { @Override public void run() { - while(running) { + while (running) { + if (stopOnNoMessageAvailable) { + try { + if (!reader.hasMessageAvailable()) { + break; + } + } catch (PulsarClientException e) { + log.error("Received exception while testing hasMessageAvailable", e); + errorNotifier.triggerError(e); + } + } try { Message<byte[]> msg = reader.readNext(); processRequest(msg); } catch (Throwable th) { - if (running) { + if (running && !stopOnNoMessageAvailable) { Review comment: I don't think we should check "! stopOnNoMessageAvailable". If errors occur while stopOnNoMessageAvailable=true, we still need to correctly handle the exception and not ignore it because that means we didn't process all messages successfully ---------------------------------------------------------------- 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: us...@infra.apache.org