@@ -294,15 +294,11 @@ public void markCurrentBeanAsProcessed(ValueContext<?, ?> valueContext) {
294
294
markCurrentBeanAsProcessedForCurrentPath ( valueContext .getCurrentBean (), valueContext .getPropertyPath () );
295
295
}
296
296
297
- public void addConstraintFailure (ConstraintViolation <T > failingConstraintViolation ) {
298
- this .failingConstraintViolations .add ( failingConstraintViolation );
299
- }
300
-
301
297
public Set <ConstraintViolation <T >> getFailingConstraints () {
302
298
return failingConstraintViolations ;
303
299
}
304
300
305
- public ConstraintViolation < T > createConstraintViolation (
301
+ public void addConstraintFailure (
306
302
ValueContext <?, ?> localContext ,
307
303
ConstraintViolationCreationContext constraintViolationCreationContext ,
308
304
ConstraintDescriptor <?> descriptor
@@ -318,10 +314,10 @@ public ConstraintViolation<T> createConstraintViolation(
318
314
// at this point we make a copy of the path to avoid side effects
319
315
Path path = PathImpl .createCopy ( constraintViolationCreationContext .getPath () );
320
316
Object dynamicPayload = constraintViolationCreationContext .getDynamicPayload ();
321
-
317
+ ConstraintViolation < T > violation ;
322
318
switch ( validationOperation ) {
323
319
case PARAMETER_VALIDATION :
324
- return ConstraintViolationImpl .forParameterValidation (
320
+ violation = ConstraintViolationImpl .forParameterValidation (
325
321
messageTemplate ,
326
322
constraintViolationCreationContext .getMessageParameters (),
327
323
constraintViolationCreationContext .getExpressionVariables (),
@@ -336,8 +332,9 @@ public ConstraintViolation<T> createConstraintViolation(
336
332
executableParameters ,
337
333
dynamicPayload
338
334
);
335
+ break ;
339
336
case RETURN_VALUE_VALIDATION :
340
- return ConstraintViolationImpl .forReturnValueValidation (
337
+ violation = ConstraintViolationImpl .forReturnValueValidation (
341
338
messageTemplate ,
342
339
constraintViolationCreationContext .getMessageParameters (),
343
340
constraintViolationCreationContext .getExpressionVariables (),
@@ -352,8 +349,9 @@ public ConstraintViolation<T> createConstraintViolation(
352
349
executableReturnValue ,
353
350
dynamicPayload
354
351
);
352
+ break ;
355
353
default :
356
- return ConstraintViolationImpl .forBeanValidation (
354
+ violation = ConstraintViolationImpl .forBeanValidation (
357
355
messageTemplate ,
358
356
constraintViolationCreationContext .getMessageParameters (),
359
357
constraintViolationCreationContext .getExpressionVariables (),
@@ -368,6 +366,8 @@ public ConstraintViolation<T> createConstraintViolation(
368
366
dynamicPayload
369
367
);
370
368
}
369
+
370
+ this .failingConstraintViolations .add ( violation );
371
371
}
372
372
373
373
public boolean hasMetaConstraintBeenProcessed (Object bean , Path path , MetaConstraint <?> metaConstraint ) {
0 commit comments