How to avoid null-checks in stages?
Current situation:
The stage has to check for an empty input port.
If the input port is empty, the AbstractConsumerStage
throws a cached EMPTY_INPUT_PORT_EXCEPTION
.
Problem:
The null-checks are uncomfortable and could be forgotten by the stage developer.
A solution:
Consider to invoke execute()
only, if at least one input port has an element (for inter-thread scenarios).
Moreover, consider to also pass the input port via execute()
to avoid null-checks.