INT-3848: ERROR log for the null beanName
JIRA: https://jira.spring.io/browse/INT-3848 When the `ConsumerEndpointFactoryBean` is created programmatically the `beanName` property may be missed and the `catch` for the `NPE` just hides an issue with the `DEBUG` log message. Add check for the `null` on the `bean` and log the issue on ERROR level. **Cherry-pick to the 4.1.x, 4.0.x and 3.0.x**
This commit is contained in:
committed by
Gary Russell
parent
b09cba64e0
commit
e54609bb76
@@ -139,23 +139,30 @@ public class ConsumerEndpointFactoryBean
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
try {
|
||||
if (!this.beanName.startsWith("org.springframework")) {
|
||||
MessageHandler targetHandler = this.handler;
|
||||
if (AopUtils.isAopProxy(targetHandler)) {
|
||||
Object target = ((Advised) targetHandler).getTargetSource().getTarget();
|
||||
if (target instanceof MessageHandler) {
|
||||
targetHandler = (MessageHandler) target;
|
||||
if (this.beanName == null) {
|
||||
logger.error("The MessageHandler [" + this.handler + "] will be created without a 'componentName'. " +
|
||||
"Consider specifying the 'beanName' property on this ConsumerEndpointFactoryBean.");
|
||||
}
|
||||
else {
|
||||
try {
|
||||
if (!this.beanName.startsWith("org.springframework")) {
|
||||
MessageHandler targetHandler = this.handler;
|
||||
if (AopUtils.isAopProxy(targetHandler)) {
|
||||
Object target = ((Advised) targetHandler).getTargetSource().getTarget();
|
||||
if (target instanceof MessageHandler) {
|
||||
targetHandler = (MessageHandler) target;
|
||||
}
|
||||
}
|
||||
if (targetHandler instanceof IntegrationObjectSupport) {
|
||||
((IntegrationObjectSupport) targetHandler).setComponentName(this.beanName);
|
||||
}
|
||||
}
|
||||
if (targetHandler instanceof IntegrationObjectSupport) {
|
||||
((IntegrationObjectSupport) targetHandler).setComponentName(this.beanName);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Could not set component name for handler "
|
||||
+ this.handler + " for " + this.beanName + " :" + e.getMessage());
|
||||
catch (Exception e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Could not set component name for handler "
|
||||
+ this.handler + " for " + this.beanName + " :" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(this.adviceChain)) {
|
||||
|
||||
Reference in New Issue
Block a user