From 44f438d3f202ba1bb40446a66bf2aacf08f47e52 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Tue, 19 Feb 2019 15:06:40 -0500 Subject: [PATCH] GH-2752: RequestMapping: react only for our event Fixes https://github.com/spring-projects/spring-integration/issues/2752 The logic in the `IntegrationRequestMappingHandlerMapping` fully depends on the application context it has been registered with, therefore any arbitrary `ContextRefreshedEvent` doesn't fit our requirements. More over it may cause a problem with missed mappings when parent-child configuration is used. **Chery-pick to 5.1.x, 5.0.x & 4.3.x** --- .../IntegrationRequestMappingHandlerMapping.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/IntegrationRequestMappingHandlerMapping.java b/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/IntegrationRequestMappingHandlerMapping.java index 71f9c30da5..c56e50df76 100644 --- a/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/IntegrationRequestMappingHandlerMapping.java +++ b/spring-integration-http/src/main/java/org/springframework/integration/http/inbound/IntegrationRequestMappingHandlerMapping.java @@ -187,11 +187,6 @@ public final class IntegrationRequestMappingHandlerMapping extends RequestMappin return createRequestMappingInfo(requestMappingAnnotation, getCustomTypeCondition(endpoint.getClass())); } - @Override - public void afterPropertiesSet() { - // No-op in favor of onApplicationEvent - } - /** * {@link HttpRequestHandlingEndpointSupport}s may depend on auto-created * {@code requestChannel}s, so MVC Handlers detection should be postponed @@ -200,9 +195,14 @@ public final class IntegrationRequestMappingHandlerMapping extends RequestMappin */ @Override public void onApplicationEvent(ContextRefreshedEvent event) { - if (!this.initialized.getAndSet(true)) { + if (event.getApplicationContext().equals(getApplicationContext()) && !this.initialized.getAndSet(true)) { super.afterPropertiesSet(); } } + @Override + public void afterPropertiesSet() { + // No-op in favor of onApplicationEvent + } + }