From 5fe014ba481a0d212599cda7bb86b71d53ac87c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Wed, 3 Nov 2021 09:24:29 +0100 Subject: [PATCH 1/3] Allow disabling Hibernate Search through configuration properties --- .../ConfigDisabledAndIndexedEntityTest.java | 40 +++++++++++++++++++ .../HibernateSearchElasticsearchRecorder.java | 6 +++ ...ticsearchRuntimeConfigPersistenceUnit.java | 6 +++ 3 files changed, 52 insertions(+) create mode 100644 extensions/hibernate-search-orm-elasticsearch/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/test/configuration/ConfigDisabledAndIndexedEntityTest.java diff --git a/extensions/hibernate-search-orm-elasticsearch/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/test/configuration/ConfigDisabledAndIndexedEntityTest.java b/extensions/hibernate-search-orm-elasticsearch/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/test/configuration/ConfigDisabledAndIndexedEntityTest.java new file mode 100644 index 0000000000000..2250241826363 --- /dev/null +++ b/extensions/hibernate-search-orm-elasticsearch/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/test/configuration/ConfigDisabledAndIndexedEntityTest.java @@ -0,0 +1,40 @@ +package io.quarkus.hibernate.search.elasticsearch.test.configuration; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import javax.inject.Inject; + +import org.hibernate.SessionFactory; +import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.SearchMapping; +import org.hibernate.search.util.common.SearchException; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.arc.Arc; +import io.quarkus.test.QuarkusUnitTest; + +public class ConfigDisabledAndIndexedEntityTest { + + @RegisterExtension + static final QuarkusUnitTest config = new QuarkusUnitTest().setArchiveProducer( + () -> ShrinkWrap.create(JavaArchive.class).addClass(IndexedEntity.class)) + .withConfigurationResource("application.properties") + .overrideConfigKey("quarkus.hibernate-search-orm.enabled", "false"); + + @Inject + SessionFactory sessionFactory; + + @Test + public void testDisabled() { + assertThatThrownBy(() -> Arc.container().instance(SearchMapping.class).get()) + .isInstanceOf(SearchException.class) + .hasMessageContaining("Hibernate Search was not initialized"); + + assertThatThrownBy(() -> Search.mapping(sessionFactory)) + .isInstanceOf(SearchException.class) + .hasMessageContaining("Hibernate Search was not initialized"); + } +} diff --git a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java index 488168546d1f6..d3b3824f3df5a 100644 --- a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java +++ b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java @@ -190,6 +190,12 @@ private HibernateSearchIntegrationRuntimeInitListener( @Override public void contributeRuntimeProperties(BiConsumer propertyCollector) { + if (!runtimeConfig.enabled) { + addConfig(propertyCollector, HibernateOrmMapperSettings.ENABLED, false); + // Do not process other properties: Hibernate Search is disabled anyway. + return; + } + addConfig(propertyCollector, HibernateOrmMapperSettings.SCHEMA_MANAGEMENT_STRATEGY, runtimeConfig.schemaManagement.strategy); diff --git a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRuntimeConfigPersistenceUnit.java b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRuntimeConfigPersistenceUnit.java index 45ac19181ee4f..a4f67ac011363 100644 --- a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRuntimeConfigPersistenceUnit.java +++ b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRuntimeConfigPersistenceUnit.java @@ -22,6 +22,12 @@ @ConfigGroup public class HibernateSearchElasticsearchRuntimeConfigPersistenceUnit { + /** + * Whether Hibernate Search is enabled. + */ + @ConfigItem(defaultValue = "true") + boolean enabled; + /** * Default backend */ From d725bc8fad1963a3fe7debf7bc15082a8a5835be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Wed, 3 Nov 2021 09:06:15 +0100 Subject: [PATCH 2/3] Avoid failures caused by invalid configuration when Hibernate Search is disabled because there are no indexed entities --- ...ateSearchOrmElasticsearchAwsProcessor.java | 12 +++++----- .../MissingRegionSigningDisabledTest.java | 7 +++--- ...gionSigningEnabledNoIndexedEntityTest.java | 22 +++++++++++++++++ .../MissingRegionSigningEnabledTest.java | 5 ++-- .../test/configuration/NonIndexedEntity.java | 24 +++++++++++++++++++ ...missing-region-signing-disabled.properties | 15 ------------ ...bled.properties => application.properties} | 2 -- ...HibernateSearchElasticsearchProcessor.java | 8 +++---- 8 files changed, 63 insertions(+), 32 deletions(-) create mode 100644 extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/MissingRegionSigningEnabledNoIndexedEntityTest.java create mode 100644 extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/NonIndexedEntity.java delete mode 100644 extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/resources/application-missing-region-signing-disabled.properties rename extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/resources/{application-missing-region-signing-enabled.properties => application.properties} (90%) diff --git a/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/aws/HibernateSearchOrmElasticsearchAwsProcessor.java b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/aws/HibernateSearchOrmElasticsearchAwsProcessor.java index 7398e07dc1744..26d058f857ee9 100644 --- a/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/aws/HibernateSearchOrmElasticsearchAwsProcessor.java +++ b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/aws/HibernateSearchOrmElasticsearchAwsProcessor.java @@ -6,8 +6,8 @@ import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.hibernate.orm.deployment.PersistenceUnitDescriptorBuildItem; import io.quarkus.hibernate.orm.deployment.integration.HibernateOrmIntegrationRuntimeConfiguredBuildItem; +import io.quarkus.hibernate.search.orm.elasticsearch.HibernateSearchElasticsearchPersistenceUnitConfiguredBuildItem; import io.quarkus.hibernate.search.orm.elasticsearch.aws.runtime.HibernateSearchOrmElasticsearchAwsRecorder; import io.quarkus.hibernate.search.orm.elasticsearch.aws.runtime.HibernateSearchOrmElasticsearchAwsRuntimeConfig; @@ -19,14 +19,14 @@ class HibernateSearchOrmElasticsearchAwsProcessor { @Record(ExecutionTime.RUNTIME_INIT) void setRuntimeConfig(HibernateSearchOrmElasticsearchAwsRecorder recorder, HibernateSearchOrmElasticsearchAwsRuntimeConfig runtimeConfig, - List persistenceUnitDescriptorBuildItems, + List configuredPersistenceUnits, BuildProducer runtimeConfigured) { - for (PersistenceUnitDescriptorBuildItem puDescriptor : persistenceUnitDescriptorBuildItems) { + for (HibernateSearchElasticsearchPersistenceUnitConfiguredBuildItem configuredPersistenceUnit : configuredPersistenceUnits) { + String puName = configuredPersistenceUnit.getPersistenceUnitName(); runtimeConfigured.produce(new HibernateOrmIntegrationRuntimeConfiguredBuildItem( - HIBERNATE_SEARCH_ORM_ELASTICSEARCH_AWS, - puDescriptor.getPersistenceUnitName()) + HIBERNATE_SEARCH_ORM_ELASTICSEARCH_AWS, puName) .setInitListener( - recorder.createRuntimeInitListener(runtimeConfig, puDescriptor.getPersistenceUnitName()))); + recorder.createRuntimeInitListener(runtimeConfig, puName))); } } diff --git a/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/MissingRegionSigningDisabledTest.java b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/MissingRegionSigningDisabledTest.java index 192c8963461a9..37007c8f35a18 100644 --- a/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/MissingRegionSigningDisabledTest.java +++ b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/MissingRegionSigningDisabledTest.java @@ -11,11 +11,12 @@ public class MissingRegionSigningDisabledTest { @RegisterExtension static final QuarkusUnitTest config = new QuarkusUnitTest().setArchiveProducer( - () -> ShrinkWrap.create(JavaArchive.class).addClass(IndexedEntity.class) - .addAsResource("application-missing-region-signing-disabled.properties", "application.properties")); + () -> ShrinkWrap.create(JavaArchive.class).addClass(IndexedEntity.class)) + .withConfigurationResource("application.properties") + .overrideConfigKey("quarkus.hibernate-search-orm.elasticsearch.aws.signing.enabled", "false"); @Test public void testNoConfig() { - // Just check there are no exceptions on startup, on contrary to MissingRegionTest + // Just check there are no exceptions on startup, on contrary to MissingRegionSigningEnabledTest } } diff --git a/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/MissingRegionSigningEnabledNoIndexedEntityTest.java b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/MissingRegionSigningEnabledNoIndexedEntityTest.java new file mode 100644 index 0000000000000..c26cb53f69527 --- /dev/null +++ b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/MissingRegionSigningEnabledNoIndexedEntityTest.java @@ -0,0 +1,22 @@ +package io.quarkus.hibernate.search.elasticsearch.aws.test.configuration; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusUnitTest; + +public class MissingRegionSigningEnabledNoIndexedEntityTest { + + @RegisterExtension + static final QuarkusUnitTest config = new QuarkusUnitTest().setArchiveProducer( + () -> ShrinkWrap.create(JavaArchive.class).addClass(NonIndexedEntity.class)) + .withConfigurationResource("application.properties") + .overrideConfigKey("quarkus.hibernate-search-orm.elasticsearch.aws.signing.enabled", "true"); + + @Test + public void testNoConfig() { + // Just check there are no exceptions on startup, on contrary to MissingRegionSigningEnabledTest + } +} diff --git a/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/MissingRegionSigningEnabledTest.java b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/MissingRegionSigningEnabledTest.java index fc13cfc4965c6..82610d6fa7d05 100644 --- a/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/MissingRegionSigningEnabledTest.java +++ b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/MissingRegionSigningEnabledTest.java @@ -14,8 +14,9 @@ public class MissingRegionSigningEnabledTest { @RegisterExtension static final QuarkusUnitTest config = new QuarkusUnitTest().setArchiveProducer( - () -> ShrinkWrap.create(JavaArchive.class).addClass(IndexedEntity.class) - .addAsResource("application-missing-region-signing-enabled.properties", "application.properties")) + () -> ShrinkWrap.create(JavaArchive.class).addClass(IndexedEntity.class)) + .withConfigurationResource("application.properties") + .overrideConfigKey("quarkus.hibernate-search-orm.elasticsearch.aws.signing.enabled", "true") .assertException(throwable -> assertThat(throwable) .isInstanceOf(RuntimeException.class) .hasMessageContainingAll( diff --git a/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/NonIndexedEntity.java b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/NonIndexedEntity.java new file mode 100644 index 0000000000000..d243adc3bb966 --- /dev/null +++ b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/NonIndexedEntity.java @@ -0,0 +1,24 @@ +package io.quarkus.hibernate.search.elasticsearch.aws.test.configuration; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +/** + * A non-indexed entity. + */ +@Entity +public class NonIndexedEntity { + + @Id + @GeneratedValue + private Long id; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } +} diff --git a/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/resources/application-missing-region-signing-disabled.properties b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/resources/application-missing-region-signing-disabled.properties deleted file mode 100644 index ebc6438d55156..0000000000000 --- a/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/resources/application-missing-region-signing-disabled.properties +++ /dev/null @@ -1,15 +0,0 @@ -quarkus.datasource.db-kind=h2 -quarkus.datasource.jdbc.url=jdbc:h2:mem:default;DB_CLOSE_DELAY=-1 - -quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect -quarkus.hibernate-orm.database.generation=drop-and-create - -quarkus.hibernate-search-orm.elasticsearch.version=7.10 -quarkus.hibernate-search-orm.automatic-indexing.synchronization.strategy=sync - -# Testing offline, so that we don't have to start an Elasticsearch container. -# Use integration tests if you really need to communicate with Elasticsearch. -quarkus.hibernate-search-orm.schema-management.strategy=none -quarkus.hibernate-search-orm.elasticsearch.version-check.enabled=false - -quarkus.hibernate-search-orm.elasticsearch.aws.signing.enabled=false diff --git a/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/resources/application-missing-region-signing-enabled.properties b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/resources/application.properties similarity index 90% rename from extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/resources/application-missing-region-signing-enabled.properties rename to extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/resources/application.properties index f0c038c67967d..d8eea12c8a02d 100644 --- a/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/resources/application-missing-region-signing-enabled.properties +++ b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/resources/application.properties @@ -11,5 +11,3 @@ quarkus.hibernate-search-orm.automatic-indexing.synchronization.strategy=sync # Use integration tests if you really need to communicate with Elasticsearch. quarkus.hibernate-search-orm.schema-management.strategy=none quarkus.hibernate-search-orm.elasticsearch.version-check.enabled=false - -quarkus.hibernate-search-orm.elasticsearch.aws.signing.enabled=true \ No newline at end of file diff --git a/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/HibernateSearchElasticsearchProcessor.java b/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/HibernateSearchElasticsearchProcessor.java index a9764dafb1f85..3527874ce3439 100644 --- a/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/HibernateSearchElasticsearchProcessor.java +++ b/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/HibernateSearchElasticsearchProcessor.java @@ -143,10 +143,10 @@ void registerBeans(List integrationRuntimeConfigBuildItems, - List persistenceUnitDescriptorBuildItems, + List configuredPersistenceUnits, BuildProducer runtimeConfigured) { - for (PersistenceUnitDescriptorBuildItem puDescriptor : persistenceUnitDescriptorBuildItems) { - String puName = puDescriptor.getPersistenceUnitName(); + for (HibernateSearchElasticsearchPersistenceUnitConfiguredBuildItem configuredPersistenceUnit : configuredPersistenceUnits) { + String puName = configuredPersistenceUnit.getPersistenceUnitName(); List integrationRuntimeInitListeners = new ArrayList<>(); for (HibernateSearchIntegrationRuntimeConfiguredBuildItem item : integrationRuntimeConfigBuildItems) { if (item.getPersistenceUnitName().equals(puName)) { @@ -156,7 +156,7 @@ void setRuntimeConfig(HibernateSearchElasticsearchRecorder recorder, runtimeConfigured.produce( new HibernateOrmIntegrationRuntimeConfiguredBuildItem(HIBERNATE_SEARCH_ELASTICSEARCH, puName) .setInitListener( - recorder.createRuntimeInitListener(runtimeConfig, puDescriptor.getPersistenceUnitName(), + recorder.createRuntimeInitListener(runtimeConfig, puName, integrationRuntimeInitListeners))); } } From f146e82531acddf4924e3181bfee25fda8635fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Wed, 3 Nov 2021 09:26:27 +0100 Subject: [PATCH 3/3] Avoid failures caused by invalid configuration when Hibernate Search is disabled explicitly It was already almost implemented, but the implementation code was not being used. This commit fixes that. --- ...ateSearchOrmElasticsearchAwsProcessor.java | 11 ++++----- ...ingEnabledHibernateSearchDisabledTest.java | 23 +++++++++++++++++++ ...IntegrationRuntimeConfiguredBuildItem.java | 2 +- .../HibernateSearchElasticsearchRecorder.java | 4 ++++ 4 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/MissingRegionSigningEnabledHibernateSearchDisabledTest.java diff --git a/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/aws/HibernateSearchOrmElasticsearchAwsProcessor.java b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/aws/HibernateSearchOrmElasticsearchAwsProcessor.java index 26d058f857ee9..6b7c04f7bfbf4 100644 --- a/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/aws/HibernateSearchOrmElasticsearchAwsProcessor.java +++ b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/aws/HibernateSearchOrmElasticsearchAwsProcessor.java @@ -6,8 +6,8 @@ import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.hibernate.orm.deployment.integration.HibernateOrmIntegrationRuntimeConfiguredBuildItem; import io.quarkus.hibernate.search.orm.elasticsearch.HibernateSearchElasticsearchPersistenceUnitConfiguredBuildItem; +import io.quarkus.hibernate.search.orm.elasticsearch.HibernateSearchIntegrationRuntimeConfiguredBuildItem; import io.quarkus.hibernate.search.orm.elasticsearch.aws.runtime.HibernateSearchOrmElasticsearchAwsRecorder; import io.quarkus.hibernate.search.orm.elasticsearch.aws.runtime.HibernateSearchOrmElasticsearchAwsRuntimeConfig; @@ -20,13 +20,12 @@ class HibernateSearchOrmElasticsearchAwsProcessor { void setRuntimeConfig(HibernateSearchOrmElasticsearchAwsRecorder recorder, HibernateSearchOrmElasticsearchAwsRuntimeConfig runtimeConfig, List configuredPersistenceUnits, - BuildProducer runtimeConfigured) { + BuildProducer runtimeConfigured) { for (HibernateSearchElasticsearchPersistenceUnitConfiguredBuildItem configuredPersistenceUnit : configuredPersistenceUnits) { String puName = configuredPersistenceUnit.getPersistenceUnitName(); - runtimeConfigured.produce(new HibernateOrmIntegrationRuntimeConfiguredBuildItem( - HIBERNATE_SEARCH_ORM_ELASTICSEARCH_AWS, puName) - .setInitListener( - recorder.createRuntimeInitListener(runtimeConfig, puName))); + runtimeConfigured.produce(new HibernateSearchIntegrationRuntimeConfiguredBuildItem( + HIBERNATE_SEARCH_ORM_ELASTICSEARCH_AWS, puName, + recorder.createRuntimeInitListener(runtimeConfig, puName))); } } diff --git a/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/MissingRegionSigningEnabledHibernateSearchDisabledTest.java b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/MissingRegionSigningEnabledHibernateSearchDisabledTest.java new file mode 100644 index 0000000000000..5004aeb51fdf6 --- /dev/null +++ b/extensions/hibernate-search-orm-elasticsearch-aws/deployment/src/test/java/io/quarkus/hibernate/search/elasticsearch/aws/test/configuration/MissingRegionSigningEnabledHibernateSearchDisabledTest.java @@ -0,0 +1,23 @@ +package io.quarkus.hibernate.search.elasticsearch.aws.test.configuration; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusUnitTest; + +public class MissingRegionSigningEnabledHibernateSearchDisabledTest { + + @RegisterExtension + static final QuarkusUnitTest config = new QuarkusUnitTest().setArchiveProducer( + () -> ShrinkWrap.create(JavaArchive.class).addClass(IndexedEntity.class)) + .withConfigurationResource("application.properties") + .overrideConfigKey("quarkus.hibernate-search-orm.elasticsearch.aws.signing.enabled", "true") + .overrideConfigKey("quarkus.hibernate-search-orm.enabled", "false"); + + @Test + public void testNoConfig() { + // Just check there are no exceptions on startup, on contrary to MissingRegionSigningEnabledTest + } +} diff --git a/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/HibernateSearchIntegrationRuntimeConfiguredBuildItem.java b/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/HibernateSearchIntegrationRuntimeConfiguredBuildItem.java index 6fcd08f8ffa26..d5161d848489c 100644 --- a/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/HibernateSearchIntegrationRuntimeConfiguredBuildItem.java +++ b/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/HibernateSearchIntegrationRuntimeConfiguredBuildItem.java @@ -3,7 +3,7 @@ import io.quarkus.builder.item.MultiBuildItem; import io.quarkus.hibernate.orm.runtime.integration.HibernateOrmIntegrationRuntimeInitListener; -public class HibernateSearchIntegrationRuntimeConfiguredBuildItem extends MultiBuildItem { +public final class HibernateSearchIntegrationRuntimeConfiguredBuildItem extends MultiBuildItem { private final String integrationName; private final String persistenceUnitName; private final HibernateOrmIntegrationRuntimeInitListener initListener; diff --git a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java index d3b3824f3df5a..b9d21126162c7 100644 --- a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java +++ b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java @@ -219,6 +219,10 @@ public void contributeRuntimeProperties(BiConsumer propertyColle .entrySet()) { contributeBackendRuntimeProperties(propertyCollector, backendEntry.getKey(), backendEntry.getValue()); } + + for (HibernateOrmIntegrationRuntimeInitListener integrationRuntimeInitListener : integrationRuntimeInitListeners) { + integrationRuntimeInitListener.contributeRuntimeProperties(propertyCollector); + } } private void contributeBackendRuntimeProperties(BiConsumer propertyCollector, String backendName,