diff --git a/spring-integration-core/src/main/java/org/springframework/integration/scattergather/ScatterGatherHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/scattergather/ScatterGatherHandler.java index 810a3910f1..96d0d92f74 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/scattergather/ScatterGatherHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/scattergather/ScatterGatherHandler.java @@ -43,6 +43,8 @@ import org.springframework.util.ClassUtils; * Scatter-Gather EIP pattern. * * @author Artem Bilan + * @author Abdul Zaheer + * * @since 4.1 */ public class ScatterGatherHandler extends AbstractReplyProducingMessageHandler implements Lifecycle { @@ -161,7 +163,7 @@ public class ScatterGatherHandler extends AbstractReplyProducingMessageHandler i @Override public void stop() { if (this.gatherEndpoint != null) { - this.gatherEndpoint.start(); + this.gatherEndpoint.stop(); } } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/scattergather/config/ScatterGatherParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/scattergather/config/ScatterGatherParserTests.java index e0bc2b19df..2c1329809a 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/scattergather/config/ScatterGatherParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/scattergather/config/ScatterGatherParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2015 the original author or authors. + * Copyright 2014-2017 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. @@ -18,6 +18,7 @@ package org.springframework.integration.scattergather.config; import static org.hamcrest.Matchers.instanceOf; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertThat; @@ -30,11 +31,12 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.Lifecycle; import org.springframework.integration.aggregator.AggregatingMessageHandler; import org.springframework.integration.channel.FixedSubscriberChannel; import org.springframework.integration.endpoint.EventDrivenConsumer; -import org.springframework.integration.scattergather.ScatterGatherHandler; import org.springframework.integration.router.RecipientListRouter; +import org.springframework.integration.scattergather.ScatterGatherHandler; import org.springframework.integration.test.util.TestUtils; import org.springframework.messaging.MessageHandler; import org.springframework.test.context.ContextConfiguration; @@ -42,6 +44,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Artem Bilan + * @author Abdul Zaheer + * * @since 4.1 */ @ContextConfiguration @@ -73,6 +77,7 @@ public class ScatterGatherParserTests { MessageHandler scatterGather = this.beanFactory.getBean("scatterGather2.handler", MessageHandler.class); assertSame(this.beanFactory.getBean("gatherChannel"), TestUtils.getPropertyValue(scatterGather, "gatherChannel")); + Lifecycle gatherEndpoint = TestUtils.getPropertyValue(scatterGather, "gatherEndpoint", Lifecycle.class); assertNotNull(TestUtils.getPropertyValue(scatterGather, "gatherEndpoint")); assertThat(TestUtils.getPropertyValue(scatterGather, "gatherEndpoint"), instanceOf(EventDrivenConsumer.class)); assertTrue(TestUtils.getPropertyValue(scatterGather, "gatherEndpoint.running", Boolean.class)); @@ -97,6 +102,11 @@ public class ScatterGatherParserTests { assertThat(scatterChannel, instanceOf(FixedSubscriberChannel.class)); assertSame(scatterer, TestUtils.getPropertyValue(scatterChannel, "handler")); + assertTrue(gatherEndpoint.isRunning()); + ((Lifecycle) scatterGather).stop(); + assertFalse(((Lifecycle) scatterGather).isRunning()); + assertFalse(gatherEndpoint.isRunning()); + } }