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 alread 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.
{noformat} Caused by: org.hibernate.search.exception.AssertionFailure: A reference has been accessed before having been initialized.
at org.hibernate.search.engine.metadata.impl.BackReference.get(BackReference.java:42)
at org.hibernate.search.engine.metadata.impl.DocumentFieldMetadata.getSourceType(DocumentFieldMetadata.java:87)
at org.hibernate.search.engine.metadata.impl.TypeMetadata.buildFieldMetadataMap(TypeMetadata.java:445)
at org.hibernate.search.engine.metadata.impl.TypeMetadata.<init>(TypeMetadata.java:183)
at org.hibernate.search.engine.metadata.impl.TypeMetadata$Builder.build(TypeMetadata.java:655)
at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.doGetTypeMetadataFor(AnnotationMetadataProvider.java:184)
at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.getTypeMetadataForContainedIn(AnnotationMetadataProvider.java:152)
at org.hibernate.search.spi.SearchIntegratorBuilder.initDocumentBuilders(SearchIntegratorBuilder.java:346)
at org.hibernate.search.spi.SearchIntegratorBuilder.buildNewSearchFactory(SearchIntegratorBuilder.java:202)
at org.hibernate.search.spi.SearchIntegratorBuilder.buildSearchIntegrator(SearchIntegratorBuilder.java:120)
at org.hibernate.search.hcore.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated(HibernateSearchSessionFactoryObserver.java:75)
at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:540)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:423)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:880)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:384)
... 86 more {noformat} |
|