]
Hardy Ferentschik resolved HV-452.
----------------------------------
Resolution: Fixed
Incorrect Paths when using fluent API to add constraints to a
context
---------------------------------------------------------------------
Key: HV-452
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HV-452
Project: Hibernate Validator
Issue Type: Bug
Components: engine
Affects Versions: 4.2.0.Beta1, 4.2.0.Beta2
Reporter: Glen Hilton
Assignee: Hardy Ferentschik
Fix For: 4.2.0.CR1
The bug actually should be found by existing test cases in
ConstraintValidatorContextTest, but there happens to be a bug there too.
First to the test case bug:
In ConstraintValidatorContextTest, within the testing utility method assertMessageAndPath
there's a call to TestUtil.assertEqualPaths. TestUtil.assertEqualPaths doesn't
assert anything it returns a boolean, this fact causes line 156:
{{assertEqualPaths( messageAndPath.getPath(), PathImpl.createPathFromString( expectedPath
) );}}
to not actually test anything. Given this testing bug, we don't know that
ConstraintValidatorContextTest.testMultipleMessages line 144:
{{assertMessageAndPath( messageAndPathList.get( 1 ), message2, "" );}}
should actually fail. As a quick and dirty fix to the test cases, we could wrap the
existing line 144 with assertTrue, so it would end up:
{{assertTrue(assertMessageAndPath( messageAndPathList.get( 1 ), message2, ""
))}}
Now two of the tests in ConstraintValidatorContextTest will fail.
These test cases appear to fail because within ConstraintValidatorContextImpl, all of the
subclasses (ErrorBuilderImpl, NodeBuilderImpl, InIterableNodeBuilderImpl) are getting
instantiated with a reference to the propertyPath at the "base" level
(ConstraintValidatorContextImpl.propertyPath). Meaning when the subclasses update the
propertyPath they are actually all updating the same underlying object, leading to
incorrect paths being created.
This bug appears to have been introduced with HV-395 as before there was code to create a
copy of the path when ErrorBuilderImpl.addNode was called. Sorry I don't have an
actual fix to provide, as I don't fully grasp HV-395. p.s. thanks for all the hard
work!
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: