From a5776524e29a0dbfee53625804a29c2d4efac3c2 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Tue, 6 Jul 2021 14:18:02 -0400 Subject: [PATCH] Fix SourcePollingChAdFB autoStartup propagation The `spring.integration.properties` can come with the `noAutoStartup` property where we can specify a source polling channel adapter endpoint to not start automatically. Turns out the `SourcePollingChannelAdapterFactoryBean` propagates its `autoStartup` property unconditionally which will skip the `noAutoStartup` value because an `AbstractEndpoint.setAutoStartup()` sets an `autoStartupSetExplicitly` state * Fix `SourcePollingChannelAdapterFactoryBean` to rely on a `Boolean` object state and don't call target endpoint `setAutoStartup()` if it was not set * Adjust `spring.integration.properties` in tests to use `noAutoStartup` for some `SourcePollingChannelAdapterFactoryBean` * Verify that property was applied in the `IntegrationFlowTests.testWithSupplierMessageSourceImpliedPoller()` **Cherry-pick to `5.4.x` & `5.3.x`** --- .../SourcePollingChannelAdapterFactoryBean.java | 12 +++++++----- .../integration/dsl/flows/IntegrationFlowTests.java | 9 ++++++++- .../resources/META-INF/spring.integration.properties | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/SourcePollingChannelAdapterFactoryBean.java b/spring-integration-core/src/main/java/org/springframework/integration/config/SourcePollingChannelAdapterFactoryBean.java index d8c831d023..899365a338 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/SourcePollingChannelAdapterFactoryBean.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/SourcePollingChannelAdapterFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ public class SourcePollingChannelAdapterFactoryBean implements FactoryBean "No poller has been defined for channel-adapter '" + this.beanName + "', and no default poller is available within the context."); } if (this.pollerMetadata.getMaxMessagesPerPoll() == Integer.MIN_VALUE) { @@ -195,7 +195,9 @@ public class SourcePollingChannelAdapterFactoryBean implements FactoryBean c.id("stringSupplierEndpoint")) .transform(toUpperCaseFunction()) .channel("suppliedChannel") .get(); diff --git a/spring-integration-core/src/test/resources/META-INF/spring.integration.properties b/spring-integration-core/src/test/resources/META-INF/spring.integration.properties index 75c9245449..3f18726a70 100644 --- a/spring-integration-core/src/test/resources/META-INF/spring.integration.properties +++ b/spring-integration-core/src/test/resources/META-INF/spring.integration.properties @@ -3,4 +3,4 @@ #spring.integration.channels.maxBroadcastSubscribers=1 spring.integration.taskScheduler.poolSize=20 spring.integration.messagingTemplate.throwExceptionOnLateReply=true -spring.integration.endpoints.noAutoStartup=fooService* +spring.integration.endpoints.noAutoStartup=fooService*,stringSupplierEndpoint