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 a64d64f517..32437030d4 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 @@ -189,11 +189,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 @@ -202,9 +197,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 + } + } diff --git a/spring-integration-webflux/src/main/java/org/springframework/integration/webflux/inbound/WebFluxIntegrationRequestMappingHandlerMapping.java b/spring-integration-webflux/src/main/java/org/springframework/integration/webflux/inbound/WebFluxIntegrationRequestMappingHandlerMapping.java index 7e35f7d849..e3a307cc80 100644 --- a/spring-integration-webflux/src/main/java/org/springframework/integration/webflux/inbound/WebFluxIntegrationRequestMappingHandlerMapping.java +++ b/spring-integration-webflux/src/main/java/org/springframework/integration/webflux/inbound/WebFluxIntegrationRequestMappingHandlerMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 the original author or authors. + * Copyright 2017-2019 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. @@ -162,7 +162,7 @@ public class WebFluxIntegrationRequestMappingHandlerMapping extends RequestMappi */ @Override public void onApplicationEvent(ContextRefreshedEvent event) { - if (!this.initialized.getAndSet(true)) { + if (event.getApplicationContext().equals(getApplicationContext()) && !this.initialized.getAndSet(true)) { super.afterPropertiesSet(); } }