From 8082f3c3f9dfb9ece5f8a9da18bde1145b6a1a4a Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Tue, 24 Sep 2024 14:33:16 -0400 Subject: [PATCH] Fix some compiler smells for Java 21 --- gradle/wrapper/gradle-wrapper.jar | Bin 43504 -> 43583 bytes gradle/wrapper/gradle-wrapper.properties | 4 +- .../amqp/inbound/AmqpInboundGateway.java | 6 +- ...alAckListenerExecutionFailedException.java | 4 +- .../support/NackedAmqpMessageException.java | 9 +- .../aggregator/MessageGroupExpiredEvent.java | 4 +- .../endpoint/EventDrivenConsumer.java | 27 +- .../endpoint/MessageProducerSupport.java | 7 +- .../integration/handler/DelayHandler.java | 1 + .../advice/CacheRequestHandlerAdvice.java | 19 +- ...ressionEvaluatingRequestHandlerAdvice.java | 2 +- .../integration/history/MessageHistory.java | 1 + .../integration/message/AdviceMessage.java | 1 + .../splitter/AbstractMessageSplitter.java | 35 +-- .../store/MessageGroupMetadata.java | 1 + .../integration/store/MessageHolder.java | 3 +- .../integration/support/MutableMessage.java | 3 +- .../support/PartialSuccessException.java | 8 +- .../config/MaxValueReleaseStrategy.java | 15 +- .../config/xml/ChainElementsFailureTests.java | 271 ++++-------------- .../endpoint/PollingEndpointStub.java | 6 +- .../ftp/server/FtpRequestEvent.java | 4 +- .../monitor/MessageSourceTests.java | 13 +- .../kafka/channel/PollableKafkaChannel.java | 9 +- .../support/KafkaSendFailureException.java | 5 +- 25 files changed, 160 insertions(+), 298 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 2c3521197d7c4586c843d1d3e9090525f1898cde..a4b76b9530d66f5e68d973ea569d8e19de379189 100644 GIT binary patch delta 3990 zcmV;H4{7l5(*nQL0Kr1kzC=_KMxQY0|W5(lc#i zH*M1^P4B}|{x<+fkObwl)u#`$GxKKV&3pg*-y6R6txw)0qU|Clf9Uds3x{_-**c=7 z&*)~RHPM>Rw#Hi1R({;bX|7?J@w}DMF>dQQU2}9yj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VxPE^ zyZzi9P%JAD6ynwHptuzP`Kox7*9h7XSMonCalv;Md0i9Vb-c*!f0ubfk?&T&T}AHh z4m8Bz{JllKcdNg?D^%a5MFQ;#1z|*}H^qHLzW)L}wp?2tY7RejtSh8<;Zw)QGJYUm z|MbTxyj*McKlStlT9I5XlSWtQGN&-LTr2XyNU+`490rg?LYLMRnz-@oKqT1hpCGqP zyRXt4=_Woj$%n5ee<3zhLF>5>`?m9a#xQH+Jk_+|RM8Vi;2*XbK- zEL6sCpaGPzP>k8f4Kh|##_imt#zJMB;ir|JrMPGW`rityK1vHXMLy18%qmMQAm4WZ zP)i30KR&5vs15)C+8dM66&$k~i|ZT;KR&5vs15)C+8dJ(sAmGPijyIz6_bsqKLSFH zlOd=TljEpH0>h4zA*dCTK&emy#FCRCs1=i^sZ9bFmXjf<6_X39E(XY)00000#N437 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 68e8816d71..8e876e1c55 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab -distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +distributionSha256Sum=1541fa36599e12857140465f3c91a97409b4512501c26f9631fb113e392c5bd1 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/inbound/AmqpInboundGateway.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/inbound/AmqpInboundGateway.java index 64d0441343..4a708885ee 100644 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/inbound/AmqpInboundGateway.java +++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/inbound/AmqpInboundGateway.java @@ -114,6 +114,7 @@ public class AmqpInboundGateway extends MessagingGatewaySupport { private AmqpInboundGateway(MessageListenerContainer listenerContainer, AmqpTemplate amqpTemplate, boolean amqpTemplateExplicitlySet) { + Assert.notNull(listenerContainer, "listenerContainer must not be null"); Assert.notNull(amqpTemplate, "'amqpTemplate' must not be null"); Assert.isNull(listenerContainer.getMessageListener(), @@ -194,7 +195,7 @@ public class AmqpInboundGateway extends MessagingGatewaySupport { * @since 4.3.10 * @see #setRetryTemplate(RetryTemplate) */ - public void setRecoveryCallback(RecoveryCallback recoveryCallback) { + public void setRecoveryCallback(RecoveryCallback recoveryCallback) { this.recoveryCallback = recoveryCallback; } @@ -341,6 +342,9 @@ public class AmqpInboundGateway extends MessagingGatewaySupport { protected class Listener implements ChannelAwareMessageListener { + protected Listener() { + } + @SuppressWarnings("unchecked") @Override public void onMessage(final Message message, final Channel channel) { diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/ManualAckListenerExecutionFailedException.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/ManualAckListenerExecutionFailedException.java index bd1b387cae..61246fc05e 100644 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/ManualAckListenerExecutionFailedException.java +++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/ManualAckListenerExecutionFailedException.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ public class ManualAckListenerExecutionFailedException extends ListenerExecution @Serial private static final long serialVersionUID = 1L; - private final Channel channel; + private final transient Channel channel; private final long deliveryTag; diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/NackedAmqpMessageException.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/NackedAmqpMessageException.java index 301b63d80d..2532003f04 100644 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/NackedAmqpMessageException.java +++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/support/NackedAmqpMessageException.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,8 @@ import org.springframework.messaging.MessagingException; * publisher confirm. * * @author Gary Russell + * @author Artem Bilan + * * @since 4.3.12 * */ @@ -32,10 +34,11 @@ public class NackedAmqpMessageException extends MessagingException { private static final long serialVersionUID = 1L; - private final Object correlationData; - private final String nackReason; + @SuppressWarnings("serial") + private final Object correlationData; + public NackedAmqpMessageException(Message message, @Nullable Object correlationData, String nackReason) { super(message); this.correlationData = correlationData; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/MessageGroupExpiredEvent.java b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/MessageGroupExpiredEvent.java index 42e7b51e52..3f45f864fd 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/MessageGroupExpiredEvent.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/MessageGroupExpiredEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2022 the original author or authors. + * Copyright 2014-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ public class MessageGroupExpiredEvent extends IntegrationEvent { private static final long serialVersionUID = -7126221042599333919L; + @SuppressWarnings("serial") private final Object groupId; private final int messageCount; @@ -44,6 +45,7 @@ public class MessageGroupExpiredEvent extends IntegrationEvent { public MessageGroupExpiredEvent(Object source, Object groupId, int messageCount, Date lastModified, Date expired, boolean discarded) { + super(source); this.groupId = groupId; this.messageCount = messageCount; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/EventDrivenConsumer.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/EventDrivenConsumer.java index 251d9af4be..d953e09691 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/EventDrivenConsumer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/EventDrivenConsumer.java @@ -45,7 +45,7 @@ public class EventDrivenConsumer extends AbstractEndpoint implements Integration Assert.notNull(handler, "handler must not be null"); this.inputChannel = inputChannel; this.handler = handler; - this.setPhase(Integer.MIN_VALUE); + setPhase(Integer.MIN_VALUE); } @Override @@ -55,11 +55,11 @@ public class EventDrivenConsumer extends AbstractEndpoint implements Integration @Override public MessageChannel getOutputChannel() { - if (this.handler instanceof MessageProducer) { - return ((MessageProducer) this.handler).getOutputChannel(); + if (this.handler instanceof MessageProducer messageProducer) { + return messageProducer.getOutputChannel(); } - else if (this.handler instanceof MessageRouter) { - return ((MessageRouter) this.handler).getDefaultOutputChannel(); + else if (this.handler instanceof MessageRouter messageRouter) { + return messageRouter.getDefaultOutputChannel(); } else { return null; @@ -75,8 +75,8 @@ public class EventDrivenConsumer extends AbstractEndpoint implements Integration protected void doStart() { this.logComponentSubscriptionEvent(true); this.inputChannel.subscribe(this.handler); - if (this.handler instanceof Lifecycle) { - ((Lifecycle) this.handler).start(); + if (this.handler instanceof Lifecycle lifecycle) { + lifecycle.start(); } } @@ -84,15 +84,16 @@ public class EventDrivenConsumer extends AbstractEndpoint implements Integration protected void doStop() { this.logComponentSubscriptionEvent(false); this.inputChannel.unsubscribe(this.handler); - if (this.handler instanceof Lifecycle) { - ((Lifecycle) this.handler).stop(); + if (this.handler instanceof Lifecycle lifecycle) { + lifecycle.stop(); } } private void logComponentSubscriptionEvent(boolean add) { - if (this.handler instanceof NamedComponent && this.inputChannel instanceof NamedComponent) { - String channelName = ((NamedComponent) this.inputChannel).getComponentName(); - String componentType = ((NamedComponent) this.handler).getComponentType(); + if (this.handler instanceof NamedComponent namedHandler + && this.inputChannel instanceof NamedComponent namedChannel) { + + String componentType = namedHandler.getComponentType(); componentType = StringUtils.hasText(componentType) ? componentType : ""; String componentName = getComponentName(); componentName = @@ -102,7 +103,7 @@ public class EventDrivenConsumer extends AbstractEndpoint implements Integration .append(componentType) .append(componentName) .append("} as a subscriber to the '") - .append(channelName) + .append(namedChannel.getComponentName()) .append("' channel"); if (add) { buffer.insert(0, "Adding "); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java index b2022b552f..ffed5aafc8 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java @@ -81,7 +81,7 @@ public abstract class MessageProducerSupport extends AbstractEndpoint private volatile Subscription subscription; protected MessageProducerSupport() { - this.setPhase(Integer.MAX_VALUE / 2); + setPhase(Integer.MAX_VALUE / 2); } @Override @@ -222,7 +222,6 @@ public abstract class MessageProducerSupport extends AbstractEndpoint if (beanFactory != null) { this.messagingTemplate.setBeanFactory(beanFactory); } - } /** @@ -278,8 +277,8 @@ public abstract class MessageProducerSupport extends AbstractEndpoint .doOnCancel(this::stop) .doOnSubscribe((subs) -> this.subscription = subs); - if (channelForSubscription instanceof ReactiveStreamsSubscribableChannel) { - ((ReactiveStreamsSubscribableChannel) channelForSubscription).subscribeTo(messageFlux); + if (channelForSubscription instanceof ReactiveStreamsSubscribableChannel reactiveStreamsSubscribableChannel) { + reactiveStreamsSubscribableChannel.subscribeTo(messageFlux); } else { messageFlux diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/DelayHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/DelayHandler.java index 42725cf30d..59e7bc9389 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/DelayHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/DelayHandler.java @@ -686,6 +686,7 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement private final long requestDate; + @SuppressWarnings("serial") private final Message original; DelayedMessageWrapper(Message original, long requestDate) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/CacheRequestHandlerAdvice.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/CacheRequestHandlerAdvice.java index 8bb6632468..efcf6313ee 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/CacheRequestHandlerAdvice.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/CacheRequestHandlerAdvice.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; +import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.SmartInitializingSingleton; import org.springframework.cache.CacheManager; import org.springframework.cache.interceptor.CacheAspectSupport; @@ -49,7 +50,7 @@ import org.springframework.util.ReflectionUtils; * The {@link AbstractRequestHandlerAdvice} implementation for caching * {@code AbstractReplyProducingMessageHandler.RequestHandler#handleRequestMessage(Message)} results. * Supports all the cache operations - cacheable, put, evict. - * By default only cacheable is applied for the provided {@code cacheNames}. + * By default, only cacheable is applied for the provided {@code cacheNames}. * The default cache {@code key} is {@code payload} of the request message. * * @author Artem Bilan @@ -103,9 +104,6 @@ public class CacheRequestHandlerAdvice extends AbstractRequestHandlerAdvice */ public CacheRequestHandlerAdvice(String... cacheNamesArg) { this.cacheNames = cacheNamesArg != null ? Arrays.copyOf(cacheNamesArg, cacheNamesArg.length) : null; - CacheableOperation.Builder builder = new CacheableOperation.Builder(); - builder.setName(toString()); - this.cacheOperations.add(builder.build()); } /** @@ -192,6 +190,11 @@ public class CacheRequestHandlerAdvice extends AbstractRequestHandlerAdvice @Override protected void onInit() { + if (this.cacheOperations.isEmpty()) { + CacheableOperation.Builder builder = new CacheableOperation.Builder(); + builder.setName(toString()); + this.cacheOperations.add(builder.build()); + } List cacheOperationsToUse; if (!ObjectUtils.isEmpty(this.cacheNames)) { cacheOperationsToUse = @@ -232,14 +235,15 @@ public class CacheRequestHandlerAdvice extends AbstractRequestHandlerAdvice builder.setKeyGenerator(operation.getKeyGenerator()); return builder.build(); }) - .collect(Collectors.toList()); + .toList(); } else { cacheOperationsToUse = this.cacheOperations; } - this.delegate.setBeanFactory(getBeanFactory()); - EvaluationContext evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory()); + BeanFactory beanFactory = getBeanFactory(); + this.delegate.setBeanFactory(beanFactory); + EvaluationContext evaluationContext = ExpressionUtils.createStandardEvaluationContext(beanFactory); this.delegate.setKeyGenerator((target, method, params) -> this.keyExpression.getValue(evaluationContext, params[0])); // NOSONAR this.delegate.setCacheOperationSources((method, targetClass) -> cacheOperationsToUse); @@ -260,7 +264,6 @@ public class CacheRequestHandlerAdvice extends AbstractRequestHandlerAdvice else { return result; } - }; return this.delegate.invoke(operationInvoker, target, message); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/ExpressionEvaluatingRequestHandlerAdvice.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/ExpressionEvaluatingRequestHandlerAdvice.java index e5582a2c16..2f1f0b3a57 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/ExpressionEvaluatingRequestHandlerAdvice.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/ExpressionEvaluatingRequestHandlerAdvice.java @@ -309,7 +309,7 @@ public class ExpressionEvaluatingRequestHandlerAdvice extends AbstractRequestHan private static final long serialVersionUID = 1L; - private final Object evaluationResult; + private final transient Object evaluationResult; public MessageHandlingExpressionEvaluatingAdviceException(Message message, String description, Throwable cause, Object evaluationResult) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistory.java b/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistory.java index 0814e3af67..b32a81c2e3 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistory.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistory.java @@ -73,6 +73,7 @@ public final class MessageHistory implements List, Serializable, Clo private static final MessageBuilderFactory MESSAGE_BUILDER_FACTORY = new DefaultMessageBuilderFactory(); + @SuppressWarnings("serial") private final List components; @Nullable diff --git a/spring-integration-core/src/main/java/org/springframework/integration/message/AdviceMessage.java b/spring-integration-core/src/main/java/org/springframework/integration/message/AdviceMessage.java index a6a742cb15..2f76b55814 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/message/AdviceMessage.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/message/AdviceMessage.java @@ -41,6 +41,7 @@ public class AdviceMessage extends GenericMessage { private static final long serialVersionUID = 1L; + @SuppressWarnings("serial") private final Message inputMessage; public AdviceMessage(T payload, Message inputMessage) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/splitter/AbstractMessageSplitter.java b/spring-integration-core/src/main/java/org/springframework/integration/splitter/AbstractMessageSplitter.java index c3bc15f860..8dc193fb37 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/splitter/AbstractMessageSplitter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/splitter/AbstractMessageSplitter.java @@ -67,7 +67,7 @@ public abstract class AbstractMessageSplitter extends AbstractReplyProducingMess * Set the applySequence flag to the specified value. Defaults to true. * @param applySequence true to apply sequence information. */ - public void setApplySequence(boolean applySequence) { + public final void setApplySequence(boolean applySequence) { this.applySequence = applySequence; } @@ -143,8 +143,7 @@ public abstract class AbstractMessageSplitter extends AbstractReplyProducingMess private Flux prepareFluxResult(Message message, Object result) { int sequenceSize = 1; Flux flux = Flux.just(result); - if (result instanceof Iterable) { - Iterable iterable = (Iterable) result; + if (result instanceof Iterable iterable) { sequenceSize = obtainSizeIfPossible(iterable); flux = Flux.fromIterable(iterable); } @@ -153,18 +152,15 @@ public abstract class AbstractMessageSplitter extends AbstractReplyProducingMess sequenceSize = items.length; flux = Flux.fromArray(items); } - else if (result instanceof Iterator) { - Iterator iter = (Iterator) result; - sequenceSize = obtainSizeIfPossible(iter); - flux = Flux.fromIterable(() -> iter); + else if (result instanceof Iterator iterator) { + sequenceSize = obtainSizeIfPossible(iterator); + flux = Flux.fromIterable(() -> iterator); } - else if (result instanceof Stream) { - Stream stream = ((Stream) result); + else if (result instanceof Stream stream) { sequenceSize = 0; flux = Flux.fromStream(stream); } - else if (result instanceof Publisher) { - Publisher publisher = (Publisher) result; + else if (result instanceof Publisher publisher) { sequenceSize = 0; flux = Flux.from(publisher); } @@ -188,8 +184,7 @@ public abstract class AbstractMessageSplitter extends AbstractReplyProducingMess int sequenceSize = 1; Iterator iterator = Collections.singleton(result).iterator(); - if (result instanceof Iterable) { - Iterable iterable = (Iterable) result; + if (result instanceof Iterable iterable) { sequenceSize = obtainSizeIfPossible(iterable); iterator = iterable.iterator(); } @@ -198,19 +193,17 @@ public abstract class AbstractMessageSplitter extends AbstractReplyProducingMess sequenceSize = items.length; iterator = Arrays.asList(items).iterator(); } - else if (result instanceof Iterator) { - Iterator iter = (Iterator) result; + else if (result instanceof Iterator iter) { sequenceSize = obtainSizeIfPossible(iter); iterator = iter; } - else if (result instanceof Stream) { - Stream stream = ((Stream) result); + else if (result instanceof Stream stream) { sequenceSize = 0; iterator = stream.iterator(); } - else if (result instanceof Publisher) { + else if (result instanceof Publisher publisher) { sequenceSize = 0; - iterator = Flux.from((Publisher) result).toIterable().iterator(); + iterator = Flux.from(publisher).toIterable().iterator(); } if (!iterator.hasNext()) { @@ -251,8 +244,8 @@ public abstract class AbstractMessageSplitter extends AbstractReplyProducingMess * @since 5.0 */ protected int obtainSizeIfPossible(Iterable iterable) { - if (iterable instanceof Collection) { - return ((Collection) iterable).size(); + if (iterable instanceof Collection collection) { + return collection.size(); } else if (JacksonPresent.isJackson2Present() && JacksonNodeHelper.isNode(iterable)) { return JacksonNodeHelper.nodeSize(iterable); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupMetadata.java b/spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupMetadata.java index b3f07e944f..6fcda7d1d9 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupMetadata.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/store/MessageGroupMetadata.java @@ -41,6 +41,7 @@ public class MessageGroupMetadata implements Serializable { private static final long serialVersionUID = 1L; + @SuppressWarnings("serial") private final List messageIds = new LinkedList<>(); private long timestamp; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/store/MessageHolder.java b/spring-integration-core/src/main/java/org/springframework/integration/store/MessageHolder.java index 088e99fb10..0c5770e4be 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/store/MessageHolder.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/store/MessageHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ public class MessageHolder implements Serializable { private static final long serialVersionUID = 1L; + @SuppressWarnings("serial") private Message message; private MessageMetadata messageMetadata; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/MutableMessage.java b/spring-integration-core/src/main/java/org/springframework/integration/support/MutableMessage.java index c54ad22a97..b53ad2ec99 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/MutableMessage.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/MutableMessage.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,6 +56,7 @@ public class MutableMessage implements Message, Serializable { private static final long serialVersionUID = -636635024258737500L; + @SuppressWarnings("serial") private final T payload; private final MutableMessageHeaders headers; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/PartialSuccessException.java b/spring-integration-core/src/main/java/org/springframework/integration/support/PartialSuccessException.java index a7649420ea..7e939ed6fb 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/PartialSuccessException.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/PartialSuccessException.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2021 the original author or authors. + * Copyright 2015-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,8 @@ import org.springframework.util.Assert; * performing multiple updates from a single message, e.g. an FTP 'mput' operation. * * @author Gary Russell + * @author Artem Bilan + * * @since 4.2 * */ @@ -34,9 +36,9 @@ public class PartialSuccessException extends MessagingException { private static final long serialVersionUID = 8810900575763284993L; - private final Collection partialResults; + private final transient Collection partialResults; - private final Collection derivedInput; + private final transient Collection derivedInput; /** * diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/MaxValueReleaseStrategy.java b/spring-integration-core/src/test/java/org/springframework/integration/config/MaxValueReleaseStrategy.java index c2d5f82725..e718fe93fe 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/MaxValueReleaseStrategy.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/MaxValueReleaseStrategy.java @@ -19,28 +19,33 @@ package org.springframework.integration.config; import java.util.Collection; import java.util.List; +/** + * @author Marius Bogoevici + * @author Dave Syer + * @author Artem Bilan + */ public class MaxValueReleaseStrategy { - private long maxValue; + private final long maxValue; public MaxValueReleaseStrategy(long maxValue) { this.maxValue = maxValue; } public boolean checkCompletenessAsList(List numbers) { - int sum = 0; + long sum = 0; for (long number : numbers) { sum += number; } - return sum >= maxValue; + return sum >= this.maxValue; } public boolean checkCompletenessAsCollection(Collection numbers) { - int sum = 0; + long sum = 0; for (long number : numbers) { sum += number; } - return sum >= maxValue; + return sum >= this.maxValue; } } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ChainElementsFailureTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ChainElementsFailureTests.java index 474ee88754..403e3dd1fd 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ChainElementsFailureTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ChainElementsFailureTests.java @@ -20,21 +20,21 @@ import java.io.ByteArrayInputStream; import java.util.Locale; import java.util.Properties; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; -import org.springframework.beans.factory.config.PropertiesFactoryBean; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException; -import org.springframework.context.ApplicationContext; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.InputStreamResource; +import org.springframework.core.io.support.PropertiesLoaderUtils; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * @author Oleg Zhurakousky @@ -46,240 +46,73 @@ public class ChainElementsFailureTests { private Locale localeBeforeTest; - @Before + @BeforeEach public void setUp() { localeBeforeTest = Locale.getDefault(); - Locale.setDefault(new Locale("en", "US")); + Locale.setDefault(Locale.forLanguageTag("en-US")); } - @After + @AfterEach public void tearDown() { Locale.setDefault(localeBeforeTest); } - @Test - public void chainServiceActivator() throws Exception { - - try { - this.bootStrap("service-activator"); - fail("Expected a XmlBeanDefinitionStoreException to be thrown."); - } - catch (XmlBeanDefinitionStoreException e) { - assertThat(e.getCause().getMessage()).isEqualTo("cvc-complex-type.3.2.2: Attribute 'input-channel' is " + - "not" + - " allowed to appear in element 'int:service-activator'."); - } - + @ParameterizedTest + @ValueSource(strings = { + "service-activator", + "aggregator", + "chain", + "delayer", + "filter", + "gateway", + "header-enricher", + "header-filter", + "header-filter", + "header-value-router", + "transformer", + "router", + "splitter", + "resequencer", + }) + void inputChannelNotAllowed(String element) { + assertThatExceptionOfType(XmlBeanDefinitionStoreException.class) + .isThrownBy(() -> bootStrap(element)) + .withStackTraceContaining( + "cvc-complex-type.3.2.2: Attribute 'input-channel' is not" + + " allowed to appear in element 'int:" + element + "'."); } @Test - public void chainAggregator() throws Exception { - - try { - this.bootStrap("aggregator"); - fail("Expected a XmlBeanDefinitionStoreException to be thrown."); - } - catch (XmlBeanDefinitionStoreException e) { - assertThat(e.getCause().getMessage()).isEqualTo("cvc-complex-type.3.2.2: Attribute 'input-channel' is " + - "not" + - " allowed to appear in element 'int:aggregator'."); - } - - } - - @Test - public void chainChain() throws Exception { - - try { - this.bootStrap("chain"); - fail("Expected a XmlBeanDefinitionStoreException to be thrown."); - } - catch (XmlBeanDefinitionStoreException e) { - assertThat(e.getCause().getMessage()).isEqualTo("cvc-complex-type.3.2.2: Attribute 'input-channel' is " + - "not" + - " allowed to appear in element 'int:chain'."); - } - } - - @Test - public void chainDelayer() throws Exception { - - try { - this.bootStrap("delayer"); - fail("Expected a XmlBeanDefinitionStoreException to be thrown."); - } - catch (XmlBeanDefinitionStoreException e) { - assertThat(e.getCause().getMessage()).isEqualTo("cvc-complex-type.3.2.2: Attribute 'input-channel' is " + - "not" + - " allowed to appear in element 'int:delayer'."); - } - } - - @Test - public void chainFilter() throws Exception { - - try { - this.bootStrap("filter"); - fail("Expected a XmlBeanDefinitionStoreException to be thrown."); - } - catch (XmlBeanDefinitionStoreException e) { - assertThat(e.getCause().getMessage()).isEqualTo("cvc-complex-type.3.2.2: Attribute 'input-channel' is " + - "not" + - " allowed to appear in element 'int:filter'."); - } - } - - @Test - public void chainGateway() throws Exception { - - try { - this.bootStrap("gateway"); - fail("Expected a XmlBeanDefinitionStoreException to be thrown."); - } - catch (XmlBeanDefinitionStoreException e) { - assertThat(e.getCause().getMessage()).isEqualTo("cvc-complex-type.3.2.2: Attribute 'input-channel' is " + - "not" + - " allowed to appear in element 'int:gateway'."); - } - } - - @Test - public void chainHeaderEnricher() throws Exception { - - try { - this.bootStrap("header-enricher"); - fail("Expected a XmlBeanDefinitionStoreException to be thrown."); - } - catch (XmlBeanDefinitionStoreException e) { - assertThat(e.getCause().getMessage()).isEqualTo("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" + - " allowed to appear in element 'int:header-enricher'."); - } - } - - @Test - public void chainHeaderFilter() throws Exception { - - try { - this.bootStrap("header-filter"); - fail("Expected a XmlBeanDefinitionStoreException to be thrown."); - } - catch (XmlBeanDefinitionStoreException e) { - assertThat(e.getCause().getMessage()).isEqualTo("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" + - " allowed to appear in element 'int:header-filter'."); - } - } - - @Test - public void chainHeaderValueRouter() throws Exception { - - try { - this.bootStrap("header-value-router"); - fail("Expected a XmlBeanDefinitionStoreException to be thrown."); - } - catch (XmlBeanDefinitionStoreException e) { - assertThat(e.getCause().getMessage()).isEqualTo("cvc-complex-type.3.2.2: Attribute 'input-channel' is " + - "not" + - " allowed to appear in element 'int:header-value-router'."); - } - } - - @Test - public void chainTransformer() throws Exception { - - try { - this.bootStrap("transformer"); - fail("Expected a XmlBeanDefinitionStoreException to be thrown."); - } - catch (XmlBeanDefinitionStoreException e) { - assertThat(e.getCause().getMessage()).isEqualTo("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" + - " allowed to appear in element 'int:transformer'."); - } - } - - @Test - public void chainRouter() throws Exception { - - try { - this.bootStrap("router"); - fail("Expected a XmlBeanDefinitionStoreException to be thrown."); - } - catch (XmlBeanDefinitionStoreException e) { - assertThat(e.getCause().getMessage()).isEqualTo("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" + - " allowed to appear in element 'int:router'."); - } - } - - @Test - public void chainSplitter() throws Exception { - - try { - this.bootStrap("splitter"); - fail("Expected a XmlBeanDefinitionStoreException to be thrown."); - } - catch (XmlBeanDefinitionStoreException e) { - assertThat(e.getCause().getMessage()).isEqualTo("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" + - " allowed to appear in element 'int:splitter'."); - } - } - - @Test - public void chainResequencer() throws Exception { - - try { - this.bootStrap("resequencer"); - fail("Expected a XmlBeanDefinitionStoreException to be thrown."); - } - catch (XmlBeanDefinitionStoreException e) { - assertThat(e.getCause().getMessage()).isEqualTo("cvc-complex-type.3.2.2: Attribute 'input-channel' is not" + - " allowed to appear in element 'int:resequencer'."); - } - } - - @Test - public void chainResequencerPoller() throws Exception { - - try { - this.bootStrap("resequencer-poller"); - fail("Expected a XmlBeanDefinitionStoreException to be thrown."); - } - catch (BeanDefinitionParsingException e) { - final String expectedMessage = "Configuration problem: " + - "'int:resequencer' must not define a 'poller' sub-element " + - "when used within a chain."; - final String actualMessage = e.getMessage(); - assertThat(actualMessage.startsWith(expectedMessage)) - .as("Error message did not start with '" + expectedMessage + - "' but instead returned: '" + actualMessage + "'").isTrue(); - } + public void chainResequencerPoller() { + assertThatExceptionOfType(BeanDefinitionParsingException.class) + .isThrownBy(() -> bootStrap("resequencer-poller")) + .withMessageStartingWith("Configuration problem: " + + "'int:resequencer' must not define a 'poller' sub-element " + + "when used within a chain."); } @Test public void testInt2755DetectDuplicateHandlerId() throws Exception { - - try { - this.bootStrap("duplicate-handler-id"); - fail("Expected a BeanDefinitionParsingException to be thrown."); - } - catch (BeanDefinitionParsingException e) { - assertThat(e.getMessage().contains("A bean definition is already registered for " + - "beanName: 'foo$child.bar.handler' within the current .")).isTrue(); - } + assertThatExceptionOfType(BeanDefinitionParsingException.class) + .isThrownBy(() -> bootStrap("duplicate-handler-id")) + .withMessageContaining("A bean definition is already registered for " + + "beanName: 'foo$child.bar.handler' within the current ."); } - private ApplicationContext bootStrap(String configProperty) throws Exception { - PropertiesFactoryBean pfb = new PropertiesFactoryBean(); - pfb.setLocation(new ClassPathResource("org/springframework/integration/config/xml/chain-elements-config.properties")); - pfb.afterPropertiesSet(); - Properties prop = pfb.getObject(); - StringBuilder buffer = new StringBuilder(); - buffer.append(prop.getProperty("xmlheaders")).append(prop.getProperty(configProperty)).append(prop.getProperty("xmlfooter")); - ByteArrayInputStream stream = new ByteArrayInputStream(buffer.toString().getBytes()); + private static void bootStrap(String configProperty) throws Exception { + Properties prop = + PropertiesLoaderUtils.loadProperties( + new ClassPathResource( + "org/springframework/integration/config/xml/chain-elements-config.properties")); + ByteArrayInputStream stream = + new ByteArrayInputStream((prop.getProperty("xmlheaders") + + prop.getProperty(configProperty) + + prop.getProperty("xmlfooter")).getBytes()); GenericApplicationContext ac = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ac); reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD); reader.loadBeanDefinitions(new InputStreamResource(stream)); ac.refresh(); - return ac; } public static class SampleService { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollingEndpointStub.java b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollingEndpointStub.java index 3f91e4e07c..c4b00d9001 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollingEndpointStub.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollingEndpointStub.java @@ -30,8 +30,10 @@ import org.springframework.scheduling.support.PeriodicTrigger; */ public class PollingEndpointStub extends AbstractPollingEndpoint { - public PollingEndpointStub() { - this.setTrigger(new PeriodicTrigger(Duration.ofMillis(500))); + @Override + protected void onInit() { + super.onInit(); + setTrigger(new PeriodicTrigger(Duration.ofMillis(500))); } @Override diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/server/FtpRequestEvent.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/server/FtpRequestEvent.java index 69d7170d54..4c6c02231e 100644 --- a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/server/FtpRequestEvent.java +++ b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/server/FtpRequestEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2019-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ public abstract class FtpRequestEvent extends ApacheMinaFtpEvent { private static final long serialVersionUID = 1L; - protected final FtpRequest request; //NOSONAR protected final + protected final transient FtpRequest request; //NOSONAR protected final public FtpRequestEvent(FtpSession source, FtpRequest request) { super(source); diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MessageSourceTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MessageSourceTests.java index 4bc8e15467..9197d2304a 100644 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MessageSourceTests.java +++ b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MessageSourceTests.java @@ -22,8 +22,7 @@ import javax.management.Attribute; import javax.management.MBeanServer; import javax.management.ObjectName; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -37,16 +36,18 @@ import org.springframework.integration.scheduling.PollerMetadata; import org.springframework.jmx.support.MBeanServerFactoryBean; import org.springframework.messaging.PollableChannel; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import static org.assertj.core.api.Assertions.assertThat; /** * @author Gary Russell + * @author Artem Bilan + * * @since 5.0 * */ -@RunWith(SpringRunner.class) +@SpringJUnitConfig @DirtiesContext public class MessageSourceTests { @@ -108,7 +109,9 @@ public class MessageSourceTests { public static class MaxFetchSource extends AbstractFetchLimitingMessageSource { - { + @Override + protected void onInit() { + super.onInit(); setMaxFetchSize(123); } diff --git a/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/channel/PollableKafkaChannel.java b/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/channel/PollableKafkaChannel.java index 2c94c23ee1..2c8cc23f6f 100644 --- a/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/channel/PollableKafkaChannel.java +++ b/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/channel/PollableKafkaChannel.java @@ -59,9 +59,14 @@ public class PollableKafkaChannel extends AbstractKafkaChannel public PollableKafkaChannel(KafkaOperations template, KafkaMessageSource source) { super(template, topic(source)); this.source = source; - if (source.getConsumerProperties().getGroupId() == null) { + } + + @Override + protected void onInit() { + super.onInit(); + if (this.source.getConsumerProperties().getGroupId() == null) { String groupId = getGroupId(); - source.getConsumerProperties().setGroupId(groupId != null ? groupId : getBeanName()); + this.source.getConsumerProperties().setGroupId(groupId != null ? groupId : getBeanName()); } } diff --git a/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/support/KafkaSendFailureException.java b/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/support/KafkaSendFailureException.java index 0f223d1431..5ca48242ca 100644 --- a/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/support/KafkaSendFailureException.java +++ b/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/support/KafkaSendFailureException.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.springframework.messaging.MessagingException; * An exception that is the payload of an {@code ErrorMessage} when a send fails. * * @author Gary Russell + * @author Artem Bilan * * @since 5.4 * @@ -33,7 +34,7 @@ public class KafkaSendFailureException extends MessagingException { private static final long serialVersionUID = 1L; - private final ProducerRecord record; + private final transient ProducerRecord record; public KafkaSendFailureException(Message message, ProducerRecord record, Throwable cause) { super(message, cause);