Skip to content

Commit 53d4faa

Browse files
committed
Fix new Sonar smells
* Use method chain in the `AggregatorSpec.processor()` * Add JavaDoc to the `AvroHeaders.PREFIX`
1 parent 9a2b75b commit 53d4faa

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ public AggregatorSpec processor(Object target) {
6666
* @return the handler spec.
6767
*/
6868
public AggregatorSpec processor(Object target, String methodName) {
69-
super.processor(target);
70-
return outputProcessor(methodName != null
71-
? new MethodInvokingMessageGroupProcessor(target, methodName)
72-
: new MethodInvokingMessageGroupProcessor(target));
69+
return super.processor(target)
70+
.outputProcessor(methodName != null
71+
? new MethodInvokingMessageGroupProcessor(target, methodName)
72+
: new MethodInvokingMessageGroupProcessor(target));
7373
}
7474

7575
/**

spring-integration-core/src/main/java/org/springframework/integration/transformer/SimpleFromAvroTransformer.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
* from {@code byte[]}.
4040
*
4141
* @author Gary Russell
42+
* @author Artem Bilan
43+
*
4244
* @since 5.2
4345
*
4446
*/
@@ -48,8 +50,8 @@ public class SimpleFromAvroTransformer extends AbstractTransformer implements Be
4850

4951
private final DecoderFactory decoderFactory = new DecoderFactory();
5052

51-
private Expression typeIdExpression = new FunctionExpression<Message<?>>(
52-
msg -> msg.getHeaders().get(AvroHeaders.TYPE));
53+
private Expression typeIdExpression =
54+
new FunctionExpression<Message<?>>((message) -> message.getHeaders().get(AvroHeaders.TYPE));
5355

5456
private EvaluationContext evaluationContext;
5557

@@ -76,19 +78,23 @@ public void setBeanClassLoader(ClassLoader classLoader) {
7678
* @return the transformer
7779
*/
7880
public SimpleFromAvroTransformer typeExpression(Expression expression) {
79-
Assert.notNull(expression, "'expression' must not be null");
81+
assertExpressionNotNull(expression);
8082
this.typeIdExpression = expression;
8183
return this;
8284
}
8385

86+
private void assertExpressionNotNull(Object expression) {
87+
Assert.notNull(expression, "'expression' must not be null");
88+
}
89+
8490
/**
8591
* Set the expression to evaluate against the message to determine the type id.
8692
* Default {@code headers['avro_type']}.
8793
* @param expression the expression.
8894
* @return the transformer
8995
*/
9096
public SimpleFromAvroTransformer typeExpression(String expression) {
91-
Assert.notNull(expression, "'expression' must not be null");
97+
assertExpressionNotNull(expression);
9298
this.typeIdExpression = EXPRESSION_PARSER.parseExpression(expression);
9399
return this;
94100
}
@@ -99,7 +105,7 @@ public SimpleFromAvroTransformer typeExpression(String expression) {
99105
* @param expression the expression.
100106
*/
101107
public void setTypeExpression(Expression expression) {
102-
Assert.notNull(expression, "'expression' must not be null");
108+
assertExpressionNotNull(expression);
103109
this.typeIdExpression = expression;
104110
}
105111

@@ -109,7 +115,7 @@ public void setTypeExpression(Expression expression) {
109115
* @param expression the expression.
110116
*/
111117
public void setTypeExpression(String expression) {
112-
Assert.notNull(expression, "'expression' must not be null");
118+
assertExpressionNotNull(expression);
113119
this.typeIdExpression = EXPRESSION_PARSER.parseExpression(expression);
114120
}
115121

@@ -147,5 +153,4 @@ else if (value instanceof String) {
147153
}
148154
}
149155

150-
151156
}

spring-integration-core/src/main/java/org/springframework/integration/transformer/support/AvroHeaders.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
* Pre-defined names and prefixes for Apache Avro related headers.
2121
*
2222
* @author Gary Russell
23+
* @author Artem Bilan
24+
*
2325
* @since 5.2
2426
*/
2527
public final class AvroHeaders {
@@ -28,11 +30,14 @@ private AvroHeaders() {
2830
super();
2931
}
3032

31-
public static final String PREFIX = "avro";
33+
/**
34+
* The prefix for Apache Avro specific message headers.
35+
*/
36+
public static final String PREFIX = "avro_";
3237

3338
/**
3439
* The {@code SpecificRecord} type.
3540
*/
36-
public static final String TYPE = PREFIX + "_type";
41+
public static final String TYPE = PREFIX + "type";
3742

3843
}

spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/AbstractRSocketConnector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.springframework.core.codec.StringDecoder;
2828
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
2929
import org.springframework.messaging.rsocket.RSocketStrategies;
30-
import org.springframework.messaging.rsocket.annotation.support.DefaultMetadataExtractor;
3130
import org.springframework.messaging.rsocket.annotation.support.MetadataExtractor;
3231
import org.springframework.util.Assert;
3332
import org.springframework.util.MimeType;
@@ -126,8 +125,9 @@ public void setEndpoints(IntegrationRSocketEndpoint... endpoints) {
126125
/**
127126
* Configure a {@link MetadataExtractor} to extract the route and possibly
128127
* other metadata from the first payload of incoming requests.
129-
* <p>By default this is a {@link DefaultMetadataExtractor} with the
130-
* configured {@link RSocketStrategies} (and decoders), extracting a route
128+
* <p>By default this is a
129+
* {@link org.springframework.messaging.rsocket.annotation.support.DefaultMetadataExtractor}
130+
* with the configured {@link RSocketStrategies} (and decoders), extracting a route
131131
* from {@code "message/x.rsocket.routing.v0"} or {@code "text/plain"}
132132
* metadata entries.
133133
* @param extractor the extractor to use

0 commit comments

Comments
 (0)