Skip to content

Commit

Permalink
Avoid failures caused by invalid configuration when Hibernate Search …
Browse files Browse the repository at this point in the history
…is disabled explicitly

It was already almost implemented, but the implementation code was not
being used. This commit fixes that.
  • Loading branch information
yrodiere committed Nov 3, 2021
1 parent 9d8de14 commit d23ef9f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -20,13 +20,12 @@ class HibernateSearchOrmElasticsearchAwsProcessor {
void setRuntimeConfig(HibernateSearchOrmElasticsearchAwsRecorder recorder,
HibernateSearchOrmElasticsearchAwsRuntimeConfig runtimeConfig,
List<HibernateSearchElasticsearchPersistenceUnitConfiguredBuildItem> configuredPersistenceUnits,
BuildProducer<HibernateOrmIntegrationRuntimeConfiguredBuildItem> runtimeConfigured) {
BuildProducer<HibernateSearchIntegrationRuntimeConfiguredBuildItem> 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)));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ public void contributeRuntimeProperties(BiConsumer<String, Object> propertyColle
.entrySet()) {
contributeBackendRuntimeProperties(propertyCollector, backendEntry.getKey(), backendEntry.getValue());
}

for (HibernateOrmIntegrationRuntimeInitListener integrationRuntimeInitListener : integrationRuntimeInitListeners) {
integrationRuntimeInitListener.contributeRuntimeProperties(propertyCollector);
}
}

private void contributeBackendRuntimeProperties(BiConsumer<String, Object> propertyCollector, String backendName,
Expand Down

0 comments on commit d23ef9f

Please sign in to comment.