Reporting errors about duplicate fields fails with an AssertionFailure when field is declared by a class bridge or class-level @Spatial

Description

Affects 5.6.6 for sure, and probably all 5.x versions after 5.6.0. Does not affect 6.x: fields are contributed differently and we already have a specific test for duplicate fields.

See https://discourse.hibernate.org/t/caused-by-org-hibernate-search-exception-assertionfailure-a-reference-has-been-accessed-before-having-been-initialized/2570

The problem is that, when there is a duplicate field contributed by a class bridge or class-level @Spatial annotation, we call documentFieldMetadata.getSourceType().getType() in org.hibernate.search.engine.metadata.impl.TypeMetadata#buildFieldMetadataMap, which is called in the constructor of TypeMetadata and thus before the back-reference is initialized, so it fails.

We should find another way to get the information than calling documentFieldMetadata.getSourceType().getType().

And yeah... there should be a test.

Environment

None

Assignee

Yoann Rodière

Reporter

Yoann Rodière

Labels

None

Suitable for new contributors

None

Feedback Requested

None

Components

Priority

Minor
Configure