I am using the findAll() method in spring data jpa to return a list of orders and I wrap them in Optional class. Within the method implementation I check if there is a data in the optional to return it or to throw a run time exception. My tables are empty, and I still got 200 code status with an empty list, why the exception is not thrown. always the if block executed?
I tried to change the condition to check for the list.get().size()>0, and I expect a run time exception, but the result is the message(orders available) with an empty list.
saif barakat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.