Skip to content

Commit 5cd36c7

Browse files
committed
Fix new Sonar smells
1 parent 442c4fa commit 5cd36c7

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

spring-integration-core/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -196,26 +196,7 @@ public void afterPropertiesSet() {
196196
"Consider specifying the 'beanName' property on this ConsumerEndpointFactoryBean.");
197197
}
198198
else {
199-
try {
200-
if (!this.beanName.startsWith("org.springframework")) {
201-
MessageHandler targetHandler = this.handler;
202-
if (AopUtils.isAopProxy(targetHandler)) {
203-
Object target = ((Advised) targetHandler).getTargetSource().getTarget();
204-
if (target instanceof MessageHandler) {
205-
targetHandler = (MessageHandler) target;
206-
}
207-
}
208-
if (targetHandler instanceof IntegrationObjectSupport) {
209-
((IntegrationObjectSupport) targetHandler).setComponentName(this.beanName);
210-
}
211-
}
212-
}
213-
catch (Exception e) {
214-
if (LOGGER.isDebugEnabled()) {
215-
LOGGER.debug("Could not set component name for handler "
216-
+ this.handler + " for " + this.beanName + " :" + e.getMessage());
217-
}
218-
}
199+
populateComponentNameIfAny();
219200
}
220201

221202
if (!(this.handler instanceof ReactiveMessageHandlerAdapter)) {
@@ -230,6 +211,29 @@ else if (!CollectionUtils.isEmpty(this.adviceChain)) {
230211
initializeEndpoint();
231212
}
232213

214+
private void populateComponentNameIfAny() {
215+
try {
216+
if (!this.beanName.startsWith("org.springframework")) {
217+
MessageHandler targetHandler = this.handler;
218+
if (AopUtils.isAopProxy(targetHandler)) {
219+
Object target = ((Advised) targetHandler).getTargetSource().getTarget();
220+
if (target instanceof MessageHandler) {
221+
targetHandler = (MessageHandler) target;
222+
}
223+
}
224+
if (targetHandler instanceof IntegrationObjectSupport) {
225+
((IntegrationObjectSupport) targetHandler).setComponentName(this.beanName);
226+
}
227+
}
228+
}
229+
catch (Exception e) {
230+
if (LOGGER.isDebugEnabled()) {
231+
LOGGER.debug("Could not set component name for handler "
232+
+ this.handler + " for " + this.beanName + " :" + e.getMessage());
233+
}
234+
}
235+
}
236+
233237
private void adviceChain() {
234238
if (!CollectionUtils.isEmpty(this.adviceChain)) {
235239
/*

spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/outbound/ReactiveMongoDbStoringMessageHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ protected void onInit() {
105105
super.onInit();
106106
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
107107
if (this.mongoTemplate == null) {
108-
ReactiveMongoTemplate mongoTemplate = new ReactiveMongoTemplate(this.mongoDbFactory, this.mongoConverter);
109-
mongoTemplate.setApplicationContext(getApplicationContext());
110-
this.mongoTemplate = mongoTemplate;
108+
ReactiveMongoTemplate template = new ReactiveMongoTemplate(this.mongoDbFactory, this.mongoConverter);
109+
template.setApplicationContext(getApplicationContext());
110+
this.mongoTemplate = template;
111111
}
112112
this.initialized = true;
113113
}

0 commit comments

Comments
 (0)