val == null ? defVal : "true".equalsIgnoreCase(val) - in this expression, the third argument is boolean, and since the ternary operator must have one static type, it will try to unbox the null, hence the NPE. Only the assignment to Boolean will cause boxing again.
Check this.