ConstraintLocation does not specify equals() and hashCode()

Description

ConstraintLocation was merged in one class in HV-645, but the hashCode() and equals() were not implemented.
Due to this, in ValidatorImpl #929

fails to recognize that two paths that are identical, are equal.

My particular case is using the JSF Mojarra application with latest hibernate-validator, and having a getter in backing bean annotated with some JSR 303 validation annotation.

equals() and hashCode() should be added as they were present in BeanConstraintLocation.

Working fine in 5.0.3.Final, for example.

Environment

None

Attachments

1

Activity

Show:

Hardy Ferentschik October 14, 2014 at 9:38 PM

Btw, the underlying problem is indeed the cache and how we use it. We access the cache multiple times during a full validation. Parts of the cache can get cleared in the middle of a validation due to memory pressure. When accessed the next time the metadata gets re-created, but now we have new instances of the metadata. Hence, we have to make sure that equals work.

Oskars Vilitis September 20, 2014 at 9:43 PM
Edited

It's not really obvious to me how this could be tested more ellegantly... I hadn't enough time to investigate thoroughly why exactly in JSF environment the validation fails, but I think it is due to the fact that at some point soft references from AnnotationMetaDataProvider.configuredBeans gets removed and therefore there are two different location elements created for base class and super class (see the test case).

In order to test this, somehow the cache needs to be disabled. Did that in quite awful way, but at least the test case shows the problem.

Adding following to ConstraintLocation fixes the issue:

Hardy Ferentschik September 17, 2014 at 6:23 PM

, thanks for the bug report. much appreciated. We are planning a 5.1.3 release anyways. We will schedule this bug for this release as well. Any chance you could provide a full test case? Or maybe you could post the configuration which fails for you?

Fixed

Details

Assignee

Reporter

Labels

Bug Testcase Reminder (view)

Bug reports should generally be accompanied by a test case!

Bug Testcase Reminder (edit)

Bug reports should generally be accompanied by a test case!

Participants

Hardy Ferentschik
Oskars Vilitis

Components

Affects versions

Priority

Created September 17, 2014 at 1:14 PM
Updated October 22, 2014 at 2:50 PM
Resolved October 14, 2014 at 11:24 AM