Fix new Sonar smells

This commit is contained in:
Artem Bilan
2020-01-16 09:05:23 -05:00
parent 442c4fa4d5
commit 5cd36c7af9
2 changed files with 27 additions and 23 deletions

View File

@@ -196,26 +196,7 @@ public class ConsumerEndpointFactoryBean
"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);
}
}
}
catch (Exception e) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Could not set component name for handler "
+ this.handler + " for " + this.beanName + " :" + e.getMessage());
}
}
populateComponentNameIfAny();
}
if (!(this.handler instanceof ReactiveMessageHandlerAdapter)) {
@@ -230,6 +211,29 @@ public class ConsumerEndpointFactoryBean
initializeEndpoint();
}
private void populateComponentNameIfAny() {
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);
}
}
}
catch (Exception e) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Could not set component name for handler "
+ this.handler + " for " + this.beanName + " :" + e.getMessage());
}
}
}
private void adviceChain() {
if (!CollectionUtils.isEmpty(this.adviceChain)) {
/*

View File

@@ -105,9 +105,9 @@ public class ReactiveMongoDbStoringMessageHandler extends AbstractReactiveMessag
super.onInit();
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
if (this.mongoTemplate == null) {
ReactiveMongoTemplate mongoTemplate = new ReactiveMongoTemplate(this.mongoDbFactory, this.mongoConverter);
mongoTemplate.setApplicationContext(getApplicationContext());
this.mongoTemplate = mongoTemplate;
ReactiveMongoTemplate template = new ReactiveMongoTemplate(this.mongoDbFactory, this.mongoConverter);
template.setApplicationContext(getApplicationContext());
this.mongoTemplate = template;
}
this.initialized = true;
}