Apache Camel – Null safe operator for ‘simple’ statement

In Apache Camel we use “simple” statement to extract values in a pojo.

For example if we have a pojo “Employee” having “employeeId” as one of the attribute, and employee object is available in camel exchange body, we can retrieve the employee id with following statement.


If by chance body is null above statement will throw null pointer exception. Apache Camel provides a solution to avoid this situation.  Use ?. instead of . to access attributes.



2 thoughts on “Apache Camel – Null safe operator for ‘simple’ statement

Leave a Reply

Your email address will not be published. Required fields are marked *