Removed unreachable code
Modified to avoid throwing NPE during logging error message
Merge branch 'SPARK-3171' of github.com:sarutak/spark into SPARK-3106