Conditional loading of AVRO message converter
Introducing a property to disable loading the AVRO message converter. When spring.cloud.stream.avro.enabled is set to false, the converter is not loaded. By default, it is enabled. Resolves https://github.com/spring-cloud/spring-cloud-function/issues/854
This commit is contained in:
@@ -166,6 +166,7 @@ public class ContextFunctionCatalogAutoConfiguration {
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(name = "org.apache.avro.Schema")
|
||||
@ConditionalOnProperty(value = "spring.cloud.stream.avro.enabled", havingValue = "true", matchIfMissing = true)
|
||||
static class AvroSchemaMessageConverterConfiguration {
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -37,6 +37,7 @@ import static org.mockito.Mockito.mock;
|
||||
* Tests the conditional loading aspects of the {@link ContextFunctionCatalogAutoConfiguration}.
|
||||
*
|
||||
* @author Chris Bono
|
||||
* @author Soby Chacko
|
||||
*/
|
||||
public class ContextFunctionCatalogAutoConfigurationConditionalLoadingTests {
|
||||
|
||||
@@ -58,6 +59,13 @@ public class ContextFunctionCatalogAutoConfigurationConditionalLoadingTests {
|
||||
.hasSingleBean(AvroSchemaMessageConverter.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void avroSchemaMessageConverterBeansNotLoadedWhenAvroOnClasspathButDisabledThroughProperty() {
|
||||
contextRunner.withPropertyValues("spring.cloud.stream.avro.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(AvroSchemaServiceManager.class)
|
||||
.doesNotHaveBean(AvroSchemaMessageConverter.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void avroSchemaMessageConverterBeansNotLoadedWhenAvroNotOnClasspath() {
|
||||
contextRunner.withClassLoader(new FilteredClassLoader(Schema.class)).run((context) ->
|
||||
|
||||
Reference in New Issue
Block a user