Skip to content

Commit baf1b97

Browse files
artembilangaryrussell
authored andcommitted
GH-2752: RequestMapping: react only for our event
Fixes #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**
1 parent 9e238f5 commit baf1b97

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

spring-integration-http/src/main/java/org/springframework/integration/http/inbound/IntegrationRequestMappingHandlerMapping.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,6 @@ private RequestMappingInfo getMappingForEndpoint(BaseHttpInboundEndpoint endpoin
234234
return createRequestMappingInfo(requestMappingAnnotation, getCustomTypeCondition(endpoint.getClass()));
235235
}
236236

237-
@Override
238-
public void afterPropertiesSet() {
239-
// No-op in favor of onApplicationEvent
240-
}
241-
242237
/**
243238
* {@link HttpRequestHandlingEndpointSupport}s may depend on auto-created
244239
* {@code requestChannel}s, so MVC Handlers detection should be postponed
@@ -247,9 +242,14 @@ public void afterPropertiesSet() {
247242
*/
248243
@Override
249244
public void onApplicationEvent(ContextRefreshedEvent event) {
250-
if (!this.initialized.getAndSet(true)) {
245+
if (event.getApplicationContext().equals(getApplicationContext()) && !this.initialized.getAndSet(true)) {
251246
super.afterPropertiesSet();
252247
}
253248
}
254249

250+
@Override
251+
public void afterPropertiesSet() {
252+
// No-op in favor of onApplicationEvent
253+
}
254+
255255
}

spring-integration-webflux/src/main/java/org/springframework/integration/webflux/inbound/WebFluxIntegrationRequestMappingHandlerMapping.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2018 the original author or authors.
2+
* Copyright 2017-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -191,7 +191,7 @@ protected CorsConfiguration initCorsConfiguration(Object handler, Method method,
191191
*/
192192
@Override
193193
public void onApplicationEvent(ContextRefreshedEvent event) {
194-
if (!this.initialized.getAndSet(true)) {
194+
if (event.getApplicationContext().equals(getApplicationContext()) && !this.initialized.getAndSet(true)) {
195195
super.afterPropertiesSet();
196196
}
197197
}

0 commit comments

Comments
 (0)