CONN-676: Addressed Null Dereferences identified by Fortify scan

Null Dereferences identified by Fortify scan addressed by:

1) Short-circuit logic for checking for nulls before dereferencing
2) Using intermediate variables so that when exceptions are thrown and caught, a null is returned instead of attempting to dereference a null variable.