INT-3916: Don't Use CTOR Injection in FactoryBean
JIRA: https://jira.spring.io/browse/INT-3916 The `JpaOutboundGatewayFactoryBean` used CTOR injection for the `JpaExecutor`. That one, in turn, uses CTOR injection for the `EntityManagerFactory`. Such a dependency may cause the `early bean instantiating` in case of `AbstractAutowireCapableBeanFactory.getSingletonFactoryBeanForTypeCheck()`. And we end up with the `BeanCurrentlyInCreationException`. Therefore no one `FactoryBean` should use CTOR injection if there is a potential hierarchical dependency. NOTE: there is no tests on the matter, since we don't change the components behavior. The `JPA` sample application will be changed to the Boot to track this fix. **Cherry-pick to 4.2.x** Address PR comments and fix other `FactoryBean`s for the same issue, when it is reasonable Polishing Address PR comments Make setter `setSockJsTaskScheduler` as `public`
This commit is contained in:
committed by
Gary Russell
parent
2be12160e9
commit
fec2a36f42
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
* Copyright 2014-2016 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.
|
||||
@@ -100,7 +100,7 @@ public class WebSocketIntegrationConfigurationInitializer implements Integration
|
||||
BeanDefinitionBuilder enableWebSocketBuilder =
|
||||
BeanDefinitionBuilder.genericBeanDefinition(WebSocketHandlerMappingFactoryBean.class)
|
||||
.setRole(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
.addConstructorArgReference("defaultSockJsTaskScheduler");
|
||||
.addPropertyReference("sockJsTaskScheduler", "defaultSockJsTaskScheduler");
|
||||
|
||||
registry.registerBeanDefinition(WEB_SOCKET_HANDLER_MAPPING_BEAN_NAME,
|
||||
enableWebSocketBuilder.getBeanDefinition());
|
||||
@@ -111,11 +111,11 @@ public class WebSocketIntegrationConfigurationInitializer implements Integration
|
||||
private static class WebSocketHandlerMappingFactoryBean extends AbstractFactoryBean<HandlerMapping>
|
||||
implements ApplicationContextAware {
|
||||
|
||||
private final ServletWebSocketHandlerRegistry registry;
|
||||
private ServletWebSocketHandlerRegistry registry;
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
private WebSocketHandlerMappingFactoryBean(ThreadPoolTaskScheduler sockJsTaskScheduler) {
|
||||
public void setSockJsTaskScheduler(ThreadPoolTaskScheduler sockJsTaskScheduler) {
|
||||
this.registry = new ServletWebSocketHandlerRegistry(sockJsTaskScheduler);
|
||||
}
|
||||
|
||||
@@ -140,6 +140,7 @@ public class WebSocketIntegrationConfigurationInitializer implements Integration
|
||||
public Class<?> getObjectType() {
|
||||
return HandlerMapping.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user