Skip to content

Commit 8082f3c

Browse files
committed
Fix some compiler smells for Java 21
1 parent fc37712 commit 8082f3c

File tree

25 files changed

+162
-300
lines changed

25 files changed

+162
-300
lines changed

gradle/wrapper/gradle-wrapper.jar

79 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
3+
distributionSha256Sum=1541fa36599e12857140465f3c91a97409b4512501c26f9631fb113e392c5bd1
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
55
networkTimeout=10000
66
validateDistributionUrl=true
77
zipStoreBase=GRADLE_USER_HOME

spring-integration-amqp/src/main/java/org/springframework/integration/amqp/inbound/AmqpInboundGateway.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public AmqpInboundGateway(MessageListenerContainer listenerContainer, AmqpTempla
114114

115115
private AmqpInboundGateway(MessageListenerContainer listenerContainer, AmqpTemplate amqpTemplate,
116116
boolean amqpTemplateExplicitlySet) {
117+
117118
Assert.notNull(listenerContainer, "listenerContainer must not be null");
118119
Assert.notNull(amqpTemplate, "'amqpTemplate' must not be null");
119120
Assert.isNull(listenerContainer.getMessageListener(),
@@ -194,7 +195,7 @@ public void setRetryTemplate(RetryTemplate retryTemplate) {
194195
* @since 4.3.10
195196
* @see #setRetryTemplate(RetryTemplate)
196197
*/
197-
public void setRecoveryCallback(RecoveryCallback<? extends Object> recoveryCallback) {
198+
public void setRecoveryCallback(RecoveryCallback<?> recoveryCallback) {
198199
this.recoveryCallback = recoveryCallback;
199200
}
200201

@@ -341,6 +342,9 @@ protected AttributeAccessor getErrorMessageAttributes(org.springframework.messag
341342

342343
protected class Listener implements ChannelAwareMessageListener {
343344

345+
protected Listener() {
346+
}
347+
344348
@SuppressWarnings("unchecked")
345349
@Override
346350
public void onMessage(final Message message, final Channel channel) {

spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/ManualAckListenerExecutionFailedException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 the original author or authors.
2+
* Copyright 2019-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ public class ManualAckListenerExecutionFailedException extends ListenerExecution
3838
@Serial
3939
private static final long serialVersionUID = 1L;
4040

41-
private final Channel channel;
41+
private final transient Channel channel;
4242

4343
private final long deliveryTag;
4444

spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/NackedAmqpMessageException.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2019 the original author or authors.
2+
* Copyright 2017-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,17 +25,20 @@
2525
* publisher confirm.
2626
*
2727
* @author Gary Russell
28+
* @author Artem Bilan
29+
*
2830
* @since 4.3.12
2931
*
3032
*/
3133
public class NackedAmqpMessageException extends MessagingException {
3234

3335
private static final long serialVersionUID = 1L;
3436

35-
private final Object correlationData;
36-
3737
private final String nackReason;
3838

39+
@SuppressWarnings("serial")
40+
private final Object correlationData;
41+
3942
public NackedAmqpMessageException(Message<?> message, @Nullable Object correlationData, String nackReason) {
4043
super(message);
4144
this.correlationData = correlationData;

spring-integration-core/src/main/java/org/springframework/integration/aggregator/MessageGroupExpiredEvent.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2022 the original author or authors.
2+
* Copyright 2014-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@ public class MessageGroupExpiredEvent extends IntegrationEvent {
3232

3333
private static final long serialVersionUID = -7126221042599333919L;
3434

35+
@SuppressWarnings("serial")
3536
private final Object groupId;
3637

3738
private final int messageCount;
@@ -44,6 +45,7 @@ public class MessageGroupExpiredEvent extends IntegrationEvent {
4445

4546
public MessageGroupExpiredEvent(Object source, Object groupId, int messageCount, Date lastModified, Date expired,
4647
boolean discarded) {
48+
4749
super(source);
4850
this.groupId = groupId;
4951
this.messageCount = messageCount;

spring-integration-core/src/main/java/org/springframework/integration/endpoint/EventDrivenConsumer.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public EventDrivenConsumer(SubscribableChannel inputChannel, MessageHandler hand
4545
Assert.notNull(handler, "handler must not be null");
4646
this.inputChannel = inputChannel;
4747
this.handler = handler;
48-
this.setPhase(Integer.MIN_VALUE);
48+
setPhase(Integer.MIN_VALUE);
4949
}
5050

5151
@Override
@@ -55,11 +55,11 @@ public MessageChannel getInputChannel() {
5555

5656
@Override
5757
public MessageChannel getOutputChannel() {
58-
if (this.handler instanceof MessageProducer) {
59-
return ((MessageProducer) this.handler).getOutputChannel();
58+
if (this.handler instanceof MessageProducer messageProducer) {
59+
return messageProducer.getOutputChannel();
6060
}
61-
else if (this.handler instanceof MessageRouter) {
62-
return ((MessageRouter) this.handler).getDefaultOutputChannel();
61+
else if (this.handler instanceof MessageRouter messageRouter) {
62+
return messageRouter.getDefaultOutputChannel();
6363
}
6464
else {
6565
return null;
@@ -75,24 +75,25 @@ public MessageHandler getHandler() {
7575
protected void doStart() {
7676
this.logComponentSubscriptionEvent(true);
7777
this.inputChannel.subscribe(this.handler);
78-
if (this.handler instanceof Lifecycle) {
79-
((Lifecycle) this.handler).start();
78+
if (this.handler instanceof Lifecycle lifecycle) {
79+
lifecycle.start();
8080
}
8181
}
8282

8383
@Override
8484
protected void doStop() {
8585
this.logComponentSubscriptionEvent(false);
8686
this.inputChannel.unsubscribe(this.handler);
87-
if (this.handler instanceof Lifecycle) {
88-
((Lifecycle) this.handler).stop();
87+
if (this.handler instanceof Lifecycle lifecycle) {
88+
lifecycle.stop();
8989
}
9090
}
9191

9292
private void logComponentSubscriptionEvent(boolean add) {
93-
if (this.handler instanceof NamedComponent && this.inputChannel instanceof NamedComponent) {
94-
String channelName = ((NamedComponent) this.inputChannel).getComponentName();
95-
String componentType = ((NamedComponent) this.handler).getComponentType();
93+
if (this.handler instanceof NamedComponent namedHandler
94+
&& this.inputChannel instanceof NamedComponent namedChannel) {
95+
96+
String componentType = namedHandler.getComponentType();
9697
componentType = StringUtils.hasText(componentType) ? componentType : "";
9798
String componentName = getComponentName();
9899
componentName =
@@ -102,7 +103,7 @@ private void logComponentSubscriptionEvent(boolean add) {
102103
.append(componentType)
103104
.append(componentName)
104105
.append("} as a subscriber to the '")
105-
.append(channelName)
106+
.append(namedChannel.getComponentName())
106107
.append("' channel");
107108
if (add) {
108109
buffer.insert(0, "Adding ");

spring-integration-core/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public abstract class MessageProducerSupport extends AbstractEndpoint
8181
private volatile Subscription subscription;
8282

8383
protected MessageProducerSupport() {
84-
this.setPhase(Integer.MAX_VALUE / 2);
84+
setPhase(Integer.MAX_VALUE / 2);
8585
}
8686

8787
@Override
@@ -222,7 +222,6 @@ protected void onInit() {
222222
if (beanFactory != null) {
223223
this.messagingTemplate.setBeanFactory(beanFactory);
224224
}
225-
226225
}
227226

228227
/**
@@ -278,8 +277,8 @@ protected void subscribeToPublisher(Publisher<? extends Message<?>> publisher) {
278277
.doOnCancel(this::stop)
279278
.doOnSubscribe((subs) -> this.subscription = subs);
280279

281-
if (channelForSubscription instanceof ReactiveStreamsSubscribableChannel) {
282-
((ReactiveStreamsSubscribableChannel) channelForSubscription).subscribeTo(messageFlux);
280+
if (channelForSubscription instanceof ReactiveStreamsSubscribableChannel reactiveStreamsSubscribableChannel) {
281+
reactiveStreamsSubscribableChannel.subscribeTo(messageFlux);
283282
}
284283
else {
285284
messageFlux

spring-integration-core/src/main/java/org/springframework/integration/handler/DelayHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@ public static final class DelayedMessageWrapper implements Serializable {
686686

687687
private final long requestDate;
688688

689+
@SuppressWarnings("serial")
689690
private final Message<?> original;
690691

691692
DelayedMessageWrapper(Message<?> original, long requestDate) {

spring-integration-core/src/main/java/org/springframework/integration/handler/advice/CacheRequestHandlerAdvice.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.function.Function;
2424
import java.util.stream.Collectors;
2525

26+
import org.springframework.beans.factory.BeanFactory;
2627
import org.springframework.beans.factory.SmartInitializingSingleton;
2728
import org.springframework.cache.CacheManager;
2829
import org.springframework.cache.interceptor.CacheAspectSupport;
@@ -49,7 +50,7 @@
4950
* The {@link AbstractRequestHandlerAdvice} implementation for caching
5051
* {@code AbstractReplyProducingMessageHandler.RequestHandler#handleRequestMessage(Message)} results.
5152
* Supports all the cache operations - cacheable, put, evict.
52-
* By default only cacheable is applied for the provided {@code cacheNames}.
53+
* By default, only cacheable is applied for the provided {@code cacheNames}.
5354
* The default cache {@code key} is {@code payload} of the request message.
5455
*
5556
* @author Artem Bilan
@@ -103,9 +104,6 @@ public class CacheRequestHandlerAdvice extends AbstractRequestHandlerAdvice
103104
*/
104105
public CacheRequestHandlerAdvice(String... cacheNamesArg) {
105106
this.cacheNames = cacheNamesArg != null ? Arrays.copyOf(cacheNamesArg, cacheNamesArg.length) : null;
106-
CacheableOperation.Builder builder = new CacheableOperation.Builder();
107-
builder.setName(toString());
108-
this.cacheOperations.add(builder.build());
109107
}
110108

111109
/**
@@ -192,6 +190,11 @@ public void afterSingletonsInstantiated() {
192190

193191
@Override
194192
protected void onInit() {
193+
if (this.cacheOperations.isEmpty()) {
194+
CacheableOperation.Builder builder = new CacheableOperation.Builder();
195+
builder.setName(toString());
196+
this.cacheOperations.add(builder.build());
197+
}
195198
List<CacheOperation> cacheOperationsToUse;
196199
if (!ObjectUtils.isEmpty(this.cacheNames)) {
197200
cacheOperationsToUse =
@@ -232,14 +235,15 @@ else if (operation instanceof CacheEvictOperation cacheEvictOperation) {
232235
builder.setKeyGenerator(operation.getKeyGenerator());
233236
return builder.build();
234237
})
235-
.collect(Collectors.toList());
238+
.toList();
236239
}
237240
else {
238241
cacheOperationsToUse = this.cacheOperations;
239242
}
240243

241-
this.delegate.setBeanFactory(getBeanFactory());
242-
EvaluationContext evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
244+
BeanFactory beanFactory = getBeanFactory();
245+
this.delegate.setBeanFactory(beanFactory);
246+
EvaluationContext evaluationContext = ExpressionUtils.createStandardEvaluationContext(beanFactory);
243247
this.delegate.setKeyGenerator((target, method, params) ->
244248
this.keyExpression.getValue(evaluationContext, params[0])); // NOSONAR
245249
this.delegate.setCacheOperationSources((method, targetClass) -> cacheOperationsToUse);
@@ -260,7 +264,6 @@ protected Object doInvoke(ExecutionCallback callback, Object target, Message<?>
260264
else {
261265
return result;
262266
}
263-
264267
};
265268

266269
return this.delegate.invoke(operationInvoker, target, message);

0 commit comments

Comments
 (0)