Fix NPE caused by setting ApplicationConnection too late (#12736)

Change-Id: Ib5b3bc7123ffd2f212fb6e242ee07175ff743b0f