Fix some compiler smells for Java 21
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 ");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<CacheOperation> 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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -73,6 +73,7 @@ public final class MessageHistory implements List<Properties>, Serializable, Clo
|
||||
|
||||
private static final MessageBuilderFactory MESSAGE_BUILDER_FACTORY = new DefaultMessageBuilderFactory();
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private final List<Properties> components;
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -41,6 +41,7 @@ public class AdviceMessage<T> extends GenericMessage<T> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private final Message<?> inputMessage;
|
||||
|
||||
public AdviceMessage(T payload, Message<?> inputMessage) {
|
||||
|
||||
@@ -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<Object> iterable = (Iterable<Object>) 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<Object> iter = (Iterator<Object>) 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<Object> stream = ((Stream<Object>) result);
|
||||
else if (result instanceof Stream<?> stream) {
|
||||
sequenceSize = 0;
|
||||
flux = Flux.fromStream(stream);
|
||||
}
|
||||
else if (result instanceof Publisher<?>) {
|
||||
Publisher<Object> publisher = (Publisher<Object>) 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<Object> iterable = (Iterable<Object>) 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<Object> iter = (Iterator<Object>) result;
|
||||
else if (result instanceof Iterator<?> iter) {
|
||||
sequenceSize = obtainSizeIfPossible(iter);
|
||||
iterator = iter;
|
||||
}
|
||||
else if (result instanceof Stream<?>) {
|
||||
Stream<Object> stream = ((Stream<Object>) 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);
|
||||
|
||||
@@ -41,6 +41,7 @@ public class MessageGroupMetadata implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private final List<UUID> messageIds = new LinkedList<>();
|
||||
|
||||
private long timestamp;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<T> implements Message<T>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = -636635024258737500L;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private final T payload;
|
||||
|
||||
private final MutableMessageHeaders headers;
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user