Skip to content

Commit 66c3eff

Browse files
committed
Fix new Sonar smells
1 parent ca56a0e commit 66c3eff

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

spring-integration-core/src/main/java/org/springframework/integration/dsl/BaseIntegrationFlowDefinition.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,12 @@ public B wireTap(WireTapSpec wireTapSpec) {
470470
WireTap interceptor = wireTapSpec.get();
471471
MessageChannel currentChannel = getCurrentMessageChannel();
472472
if (!(currentChannel instanceof InterceptableChannel)) {
473-
channel(new DirectChannel());
473+
currentChannel = new DirectChannel();
474+
channel(currentChannel);
474475
setImplicitChannel(true);
475476
}
476477
addComponent(wireTapSpec);
477-
((InterceptableChannel) getCurrentMessageChannel()).addInterceptor(interceptor);
478+
((InterceptableChannel) currentChannel).addInterceptor(interceptor);
478479
return _this();
479480
}
480481

@@ -2807,11 +2808,13 @@ public B trigger(MessageTriggerAction triggerAction,
28072808
*/
28082809
@SuppressWarnings(UNCHECKED)
28092810
public <I, O> B fluxTransform(Function<? super Flux<Message<I>>, ? extends Publisher<O>> fluxFunction) {
2810-
if (!(getCurrentMessageChannel() instanceof FluxMessageChannel)) {
2811-
channel(new FluxMessageChannel());
2811+
MessageChannel currentChannel = getCurrentMessageChannel();
2812+
if (!(currentChannel instanceof FluxMessageChannel)) {
2813+
currentChannel = new FluxMessageChannel();
2814+
channel(currentChannel);
28122815
}
28132816

2814-
Publisher<Message<I>> upstream = (Publisher<Message<I>>) getCurrentMessageChannel();
2817+
Publisher<Message<I>> upstream = (Publisher<Message<I>>) currentChannel;
28152818

28162819
Flux<Message<O>> result = Transformers.transformWithFunction(upstream, fluxFunction);
28172820

spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowDefinition.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,8 @@
2525

2626
import org.springframework.expression.Expression;
2727
import org.springframework.integration.core.GenericSelector;
28-
import org.springframework.integration.filter.MessageFilter;
29-
import org.springframework.integration.filter.MethodInvokingSelector;
3028
import org.springframework.integration.handler.BridgeHandler;
3129
import org.springframework.integration.handler.GenericHandler;
32-
import org.springframework.integration.handler.LambdaMessageProcessor;
3330
import org.springframework.integration.handler.LoggingHandler;
3431
import org.springframework.integration.handler.MessageTriggerAction;
3532
import org.springframework.integration.handler.ServiceActivatingHandler;
@@ -46,7 +43,6 @@
4643
import org.springframework.integration.transformer.GenericTransformer;
4744
import org.springframework.integration.transformer.HeaderFilter;
4845
import org.springframework.integration.transformer.MessageTransformingHandler;
49-
import org.springframework.integration.transformer.MethodInvokingTransformer;
5046
import org.springframework.messaging.Message;
5147
import org.springframework.messaging.MessageChannel;
5248
import org.springframework.messaging.MessageHandler;
@@ -80,8 +76,8 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
8076
* @param <S> the source type - 'transform from'.
8177
* @param <T> the target type - 'transform to'.
8278
* @return the current {@link IntegrationFlowDefinition}.
83-
* @see MethodInvokingTransformer
84-
* @see LambdaMessageProcessor
79+
* @see org.springframework.integration.transformer.MethodInvokingTransformer
80+
* @see org.springframework.integration.handler.LambdaMessageProcessor
8581
*/
8682
public <S, T> B transform(GenericTransformer<S, T> genericTransformer) {
8783
return transform(null, genericTransformer);
@@ -100,8 +96,8 @@ public <S, T> B transform(GenericTransformer<S, T> genericTransformer) {
10096
* @param <S> the source type - 'transform from'.
10197
* @param <T> the target type - 'transform to'.
10298
* @return the current {@link IntegrationFlowDefinition}.
103-
* @see MethodInvokingTransformer
104-
* @see LambdaMessageProcessor
99+
* @see org.springframework.integration.transformer.MethodInvokingTransformer
100+
* @see org.springframework.integration.handler.LambdaMessageProcessor
105101
* @see GenericEndpointSpec
106102
*/
107103
public <S, T> B transform(GenericTransformer<S, T> genericTransformer,
@@ -111,7 +107,8 @@ public <S, T> B transform(GenericTransformer<S, T> genericTransformer,
111107
}
112108

113109
/**
114-
* Populate a {@link MessageFilter} with {@link MethodInvokingSelector}
110+
* Populate a {@link org.springframework.integration.filter.MessageFilter}
111+
* with {@link org.springframework.integration.filter.MethodInvokingSelector}
115112
* for the provided {@link GenericSelector}.
116113
* Typically used with a Java 8 Lambda expression:
117114
* <pre class="code">
@@ -130,7 +127,8 @@ public <P> B filter(GenericSelector<P> genericSelector) {
130127
}
131128

132129
/**
133-
* Populate a {@link MessageFilter} with {@link MethodInvokingSelector}
130+
* Populate a {@link org.springframework.integration.filter.MessageFilter}
131+
* with {@link org.springframework.integration.filter.MethodInvokingSelector}
134132
* for the provided {@link GenericSelector}.
135133
* In addition accept options for the integration endpoint using {@link FilterEndpointSpec}.
136134
* Typically used with a Java 8 Lambda expression:
@@ -166,7 +164,7 @@ public <P> B filter(GenericSelector<P> genericSelector, Consumer<FilterEndpointS
166164
* @param handler the handler to invoke.
167165
* @param <P> the payload type to expect.
168166
* @return the current {@link IntegrationFlowDefinition}.
169-
* @see LambdaMessageProcessor
167+
* @see org.springframework.integration.handler.LambdaMessageProcessor
170168
*/
171169
public <P> B handle(GenericHandler<P> handler) {
172170
return handle(null, handler);
@@ -189,7 +187,7 @@ public <P> B handle(GenericHandler<P> handler) {
189187
* @param endpointConfigurer the {@link Consumer} to provide integration endpoint options.
190188
* @param <P> the payload type to expect.
191189
* @return the current {@link IntegrationFlowDefinition}.
192-
* @see LambdaMessageProcessor
190+
* @see org.springframework.integration.handler.LambdaMessageProcessor
193191
* @see GenericEndpointSpec
194192
*/
195193
public <P> B handle(GenericHandler<P> handler,
@@ -218,7 +216,7 @@ public <P> B handle(GenericHandler<P> handler,
218216
* @param endpointConfigurer the {@link Consumer} to provide integration endpoint options.
219217
* @param <P> the payload type.
220218
* @return the current {@link IntegrationFlowDefinition}.
221-
* @see LambdaMessageProcessor
219+
* @see org.springframework.integration.handler.LambdaMessageProcessor
222220
* @see SplitterEndpointSpec
223221
*/
224222
public <P> B split(Function<P, ?> splitter,
@@ -825,8 +823,8 @@ public B routeToRecipients(Consumer<RecipientListRouterSpec> routerConfigurer) {
825823
}
826824

827825
@Override
828-
public B routeByException(Consumer<RouterSpec<Class<? extends Throwable>,
829-
ErrorMessageExceptionTypeRouter>> routerConfigurer) { // NOSONAR - byte code backward compatibility
826+
public B routeByException(Consumer<RouterSpec<Class<? extends Throwable>, // NOSONAR - byte code backward compatibility
827+
ErrorMessageExceptionTypeRouter>> routerConfigurer) {
830828

831829
return super.routeByException(routerConfigurer);
832830
}

0 commit comments

Comments
 (0)