Check if not null in the constructor

Change-Id: I5e73660004e5bb8e9e3c5ba6b02d1070ee977c22