[hibernate-issues] [Hibernate-JIRA] Commented: (HV-452) Incorrect Paths when using fluent API to add constraints to a context

Hardy Ferentschik (JIRA) noreply at atlassian.com
Thu Mar 17 15:02:08 EDT 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HV-452?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=40228#action_40228 ] 

Hardy Ferentschik commented on HV-452:
--------------------------------------

I was able to reproduce the bug. Thanks for the great analysis. 

> 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: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list