Behavior change in coerceToType method with null parameter

Expression Language 3.0 introduces a behavior change when a null value is provided to the first parameter of coerceToType(Object obj, Class<?> targetType). The default coercion for null values to non-primitive types now returns null. In the following example, a null that is coerced to a Boolean now returns a null value, whereas in JavaServer Pages (JSP) 2.2 it returned false.


//factory is a javax.el.ExpressionFactory
Boolean bool=null;
factory.coerceToType(bool, java.lang.Boolean.class); 

This rule flags calls to the javax.el.ExpressionFactory coerceToType method when a primitive wrapper object is passed as the second parameter. Review your application to ensure that it can handle a null return value in this situation.

For more information on the Java EE 7 EL 3.0 implementation, see Expression Language 3.0 feature functions.