Object Graph Validation causes IllegalArgumentException on null values
----------------------------------------------------------------------

                 Key: EXTVAL-97
                 URL: https://issues.apache.org/jira/browse/EXTVAL-97
             Project: MyFaces Extensions Validator
          Issue Type: Bug
          Components: Bean Validation
    Affects Versions: 1.2.4-SNAPSHOT, 2.0.4-SNAPSHOT, 1.1.4-SNAPSHOT
            Reporter: Simon Zambrovski


Trying to validate a null-property annotated with @Valid causes an 
IllegalArgumentException:
WARNUNG: Validation of a null object
java.lang.IllegalArgumentException: Validation of a null object
        at 
org.hibernate.validator.engine.ValidatorImpl.validate(ValidatorImpl.java:110)
        at 
org.apache.myfaces.extensions.validator.beanval.BeanValidationModuleValidationInterceptorInternals.processCascadedValidation(BeanValidationModuleValidationInterceptorInternals.java:244)
        at 
org.apache.myfaces.extensions.validator.beanval.BeanValidationModuleValidationInterceptorInternals.validate(BeanValidationModuleValidationInterceptorInternals.java:228)
        at 
org.apache.myfaces.extensions.validator.beanval.BeanValidationModuleValidationInterceptor.processFieldValidation(BeanValidationModuleValidationInterceptor.java:112)
        at 
org.apache.myfaces.extensions.validator.beanval.BeanValidationModuleValidationInterceptor.processValidation(BeanValidationModuleValidationInterceptor.java:84)
        at 
org.apache.myfaces.extensions.validator.core.interceptor.AbstractValidationInterceptor.beforeGetConvertedValue(AbstractValidationInterceptor.java:135)
        at 
org.apache.myfaces.extensions.validator.core.renderkit.ExtValRendererWrapper.getConvertedValue(ExtValRendererWrapper.java:369)
        at 
org.apache.myfaces.extensions.validator.generic.renderkit.ExtValGenericRendererWrapper.intercept(ExtValGenericRendererWrapper.java:64)
        at 
org.primefaces.component.calendar.CalendarRenderer$$EnhancerByCGLIB$$77d45a8f.getConvertedValue(<generated>)
        at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1008)
        at javax.faces.component.UIInput.validate(UIInput.java:934)
        at javax.faces.component.UIInput.executeValidate(UIInput.java:1189)
        at javax.faces.component.UIInput.processValidators(UIInput.java:691)
        at 
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
        at 
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
        at 
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
        at javax.faces.component.UIForm.processValidators(UIForm.java:243)
        at 
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
        at 
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
        at 
javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1180)
        at 
com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
        at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
        at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
        at 
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:619)


In fact, a usual constraint (like @Size or @Pattern) defined by JSR-303 should 
throw this exception on null value (see 
http://jackson.codehaus.org/javadoc/bean-validation-api/1.0/javax/validation/Validator.html).

The @Valid constraint should behave differntly:
JSR303 Spec says:

3.5.1. Object graph validation
The @Valid annotation on a given association (i.e. object reference or 
collection, array, Iterable of objects), dictates
the Bean Validator implementation to apply recursively the Bean Validation 
routine on (each of) the associated
object(s). This mechanism is recursive: an associated object can itself contain 
cascaded references.
Null references are ignored.


This is a serious issue if applied on custom types, since these use converters, 
which would usually return null as a result of getAsObject(FacesContext, 
UIComponent, String) method invocation with an empty/null String. Currently, 
the ExtVal implementation allows only  to skip validation on empty String (e.G. 
using the corresponding param in web.xml).
This is not the behavior described in the spec.

See also: https://issues.apache.org/jira/browse/EXTVAL-96

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to