hen calling Validator.validateValue() with a class containing an array field with a single Pattern validation on the entire array which creates violations, the index in the path of the validations is only correct for the last item in the array. The index for the violations on other elements is always set to the index of the last element. I spent some time debugging this and found the PathImpl.createCopy(), which calls the copy constructor PathImpl(PathImpl path), is only doing a shallow copy of the values. The validation for each element in the array is using the same instance of the nodeList property in PathImpl instead of a different one for each validation. This happens because the copy constructor does not create a new list, but uses the existing one. The code that changes the currentLeafNode values is then update that list which ends up in each violation path. I believe the fix to be on line 351 of PathImpl in the 6.0.23.Final code would be to replace that line with this one.:
|