In Scala, using `return` inside a function causes a `NonLocalReturnControl` exception to be thrown and caught in order to escape the current scope.
While profiling Structured Streaming in production, it clearly shows:
This happens during a 1 minute profiling session on a single executor. The code is:
This happens because this method is converted to a function which is ran inside:
We should avoid using `return` in general, and here specifically as it is a hot path for applications using Kafka.