Hi

Yes, the response filters are expected to be run again after an exception has been mapped. The fact that the abstract CXF filter sees the original value on the 2nd run is a bug, in most case the default mapper which only creates an HTTP error is sufficient. So I guess this is why this particular issue has only been detected now.


At this stage using non-JAX-RS CXF interceptors should do it, try setting

BeanValidationInInterceptor
(in jaxrs:inInterceptors)
BeanValidationOutInterceptor
(in jaxrs:outInterceptors)

ValidationExceptionMapper

I'll address the 2nd run issue for 3.1.9

Cheers, Sergey

On 14/10/16 17:58, tomstark wrote:
I'm trying to use the JAXRSBeanValidationOutInterceptor with a customized
ValidationExceptionMapper but it throws a Fault when processing instead of
returning a response with the violations.

Here is the scenario:
When a Response is built with an entity object that has violations, the
interceptor correctly runs and throws the
ResponseConstraintViolationException with the list of violations.  This is
then handled by the ValidationExceptionMapper which builds another Response
object with a different object for the entity object (our API error object).
That in turn is also sent through the same set of outbound interceptors
causing the validation to run again.  When the validation is run again, in
the AbstractValidationInterceptor.handleMessage method the code gets the
MessageContentsList to pass to the handleValidation method.

Problem:  The MessageContentsList contains the first entity from the initial
Response instead of the new entity from the new Response.  Since I don't
have direct access to the Message object, I don't think I can affect the
MessageContentsList.  What finally ends up happening is an internal CXF
Fault is thrown instead the response that contains the violations.

Other details:
I set BeanValidationOutInterceptor.enforceOnlyBeanConstraints to true
The order of the interceptors is:  (there are other mappers/filters but
after stepping through the code, I don't think they have any effect here)
JAXRSBeanValidationInInterceptor
JAXRSBeanValidationOutInterceptor
ValidationExceptionMapper

How do I affect the MessageContentsList to return the new entity so the
validation can run on the new object instead of the one that already failed?


Thanks,

Tom




--
View this message in context: 
http://cxf.547215.n5.nabble.com/Using-JAXRSBeanValidationOutInterceptor-causes-Fault-when-validation-of-an-object-fails-tp5773878.html
Sent from the cxf-user mailing list archive at Nabble.com.



Reply via email to