Modernize code for diamond, isEmpty & pattern matching
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -45,6 +45,7 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -94,8 +95,8 @@ public abstract class AbstractAmqpChannel extends AbstractMessageChannel impleme
|
||||
AbstractAmqpChannel(AmqpTemplate amqpTemplate, AmqpHeaderMapper outboundMapper, AmqpHeaderMapper inboundMapper) {
|
||||
Assert.notNull(amqpTemplate, "amqpTemplate must not be null");
|
||||
this.amqpTemplate = amqpTemplate;
|
||||
if (amqpTemplate instanceof RabbitTemplate) {
|
||||
this.rabbitTemplate = (RabbitTemplate) amqpTemplate;
|
||||
if (amqpTemplate instanceof RabbitTemplate castRabbitTemplate) {
|
||||
this.rabbitTemplate = castRabbitTemplate;
|
||||
MessageConverter converter = this.rabbitTemplate.getMessageConverter();
|
||||
if (converter instanceof AllowedListDeserializingMessageConverter allowedListMessageConverter) {
|
||||
allowedListMessageConverter.addAllowedListPatterns(
|
||||
|
||||
@@ -47,6 +47,7 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -167,7 +168,7 @@ public class PollableAmqpChannel extends AbstractAmqpChannel
|
||||
if (traceEnabled) {
|
||||
logger.trace("preReceive on channel '" + this + "'");
|
||||
}
|
||||
if (interceptorList.getInterceptors().size() > 0) {
|
||||
if (!interceptorList.getInterceptors().isEmpty()) {
|
||||
interceptorStack = new ArrayDeque<>();
|
||||
if (!interceptorList.preReceive(this, interceptorStack)) {
|
||||
return null;
|
||||
|
||||
@@ -64,6 +64,7 @@ import org.springframework.util.ErrorHandler;
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -197,8 +198,8 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean<AbstractAmqpChan
|
||||
*/
|
||||
|
||||
public void setEncoding(String encoding) {
|
||||
if (this.amqpTemplate instanceof RabbitTemplate) {
|
||||
((RabbitTemplate) this.amqpTemplate).setEncoding(encoding);
|
||||
if (this.amqpTemplate instanceof RabbitTemplate rabbitTemplate) {
|
||||
rabbitTemplate.setEncoding(encoding);
|
||||
}
|
||||
else if (logger.isInfoEnabled()) {
|
||||
logger.info("AmqpTemplate is not a RabbitTemplate, so configured 'encoding' value will be ignored.");
|
||||
@@ -206,8 +207,8 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean<AbstractAmqpChan
|
||||
}
|
||||
|
||||
public void setMessageConverter(MessageConverter messageConverter) {
|
||||
if (this.amqpTemplate instanceof RabbitTemplate) {
|
||||
((RabbitTemplate) this.amqpTemplate).setMessageConverter(messageConverter);
|
||||
if (this.amqpTemplate instanceof RabbitTemplate rabbitTemplate) {
|
||||
rabbitTemplate.setMessageConverter(messageConverter);
|
||||
}
|
||||
else if (logger.isInfoEnabled()) {
|
||||
logger.info("AmqpTemplate is not a RabbitTemplate, so configured MessageConverter will be ignored.");
|
||||
@@ -215,8 +216,8 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean<AbstractAmqpChan
|
||||
}
|
||||
|
||||
public void setTemplateChannelTransacted(boolean channelTransacted) {
|
||||
if (this.amqpTemplate instanceof RabbitTemplate) {
|
||||
((RabbitTemplate) this.amqpTemplate).setChannelTransacted(channelTransacted);
|
||||
if (this.amqpTemplate instanceof RabbitTemplate rabbitTemplate) {
|
||||
rabbitTemplate.setChannelTransacted(channelTransacted);
|
||||
}
|
||||
else if (logger.isInfoEnabled()) {
|
||||
logger.info("AmqpTemplate is not a RabbitTemplate, so configured 'channelTransacted' will be ignored.");
|
||||
@@ -233,15 +234,15 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean<AbstractAmqpChan
|
||||
|
||||
public void setConnectionFactory(ConnectionFactory connectionFactory) {
|
||||
this.connectionFactory = connectionFactory;
|
||||
if (this.amqpTemplate instanceof RabbitTemplate) {
|
||||
((RabbitTemplate) this.amqpTemplate).setConnectionFactory(this.connectionFactory);
|
||||
if (this.amqpTemplate instanceof RabbitTemplate rabbitTemplate) {
|
||||
rabbitTemplate.setConnectionFactory(this.connectionFactory);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMessagePropertiesConverter(MessagePropertiesConverter messagePropertiesConverter) {
|
||||
this.messagePropertiesConverter = messagePropertiesConverter;
|
||||
if (this.amqpTemplate instanceof RabbitTemplate) {
|
||||
((RabbitTemplate) this.amqpTemplate).setMessagePropertiesConverter(messagePropertiesConverter);
|
||||
if (this.amqpTemplate instanceof RabbitTemplate rabbitTemplate) {
|
||||
rabbitTemplate.setMessagePropertiesConverter(messagePropertiesConverter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,8 +355,8 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean<AbstractAmqpChan
|
||||
protected AbstractAmqpChannel createInstance() {
|
||||
if (this.messageDriven) {
|
||||
AbstractMessageListenerContainer container = this.createContainer();
|
||||
if (this.amqpTemplate instanceof RabbitAccessor) {
|
||||
((RabbitAccessor) this.amqpTemplate).afterPropertiesSet();
|
||||
if (this.amqpTemplate instanceof RabbitAccessor rabbitAccessor) {
|
||||
rabbitAccessor.afterPropertiesSet();
|
||||
}
|
||||
if (this.isPubSub) {
|
||||
PublishSubscribeAmqpChannel pubsub = new PublishSubscribeAmqpChannel(
|
||||
@@ -440,38 +441,38 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean<AbstractAmqpChan
|
||||
|
||||
@Override
|
||||
public boolean isAutoStartup() {
|
||||
return (this.channel instanceof SmartLifecycle) && ((SmartLifecycle) this.channel).isAutoStartup();
|
||||
return (this.channel instanceof SmartLifecycle smartLifecycle) && smartLifecycle.isAutoStartup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPhase() {
|
||||
return (this.channel instanceof SmartLifecycle) ?
|
||||
((SmartLifecycle) this.channel).getPhase() : 0;
|
||||
return (this.channel instanceof SmartLifecycle smartLifecycle) ?
|
||||
smartLifecycle.getPhase() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return (this.channel instanceof Lifecycle) && ((Lifecycle) this.channel).isRunning();
|
||||
return (this.channel instanceof Lifecycle lifecycle) && lifecycle.isRunning();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (this.channel instanceof Lifecycle) {
|
||||
((Lifecycle) this.channel).start();
|
||||
if (this.channel instanceof Lifecycle lifecycle) {
|
||||
lifecycle.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if (this.channel instanceof Lifecycle) {
|
||||
((Lifecycle) this.channel).stop();
|
||||
if (this.channel instanceof Lifecycle lifecycle) {
|
||||
lifecycle.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(Runnable callback) {
|
||||
if (this.channel instanceof SmartLifecycle) {
|
||||
((SmartLifecycle) this.channel).stop(callback);
|
||||
if (this.channel instanceof SmartLifecycle smartLifecycle) {
|
||||
smartLifecycle.stop(callback);
|
||||
}
|
||||
else {
|
||||
callback.run();
|
||||
|
||||
@@ -63,6 +63,7 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -136,8 +137,8 @@ public class AmqpInboundChannelAdapter extends MessageProducerSupport implements
|
||||
this.messageListenerContainer = listenerContainer;
|
||||
this.messageListenerContainer.setAutoStartup(false);
|
||||
setErrorMessageStrategy(new AmqpMessageHeaderErrorMessageStrategy());
|
||||
this.abstractListenerContainer = listenerContainer instanceof AbstractMessageListenerContainer
|
||||
? (AbstractMessageListenerContainer) listenerContainer
|
||||
this.abstractListenerContainer = listenerContainer instanceof AbstractMessageListenerContainer abstractMessageListenerContainer
|
||||
? abstractMessageListenerContainer
|
||||
: null;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -123,12 +124,12 @@ public class AmqpInboundGateway extends MessagingGatewaySupport {
|
||||
this.messageListenerContainer.setAutoStartup(false);
|
||||
this.amqpTemplate = amqpTemplate;
|
||||
this.amqpTemplateExplicitlySet = amqpTemplateExplicitlySet;
|
||||
if (this.amqpTemplateExplicitlySet && this.amqpTemplate instanceof RabbitTemplate) {
|
||||
this.templateMessageConverter = ((RabbitTemplate) this.amqpTemplate).getMessageConverter();
|
||||
if (this.amqpTemplateExplicitlySet && this.amqpTemplate instanceof RabbitTemplate rabbitTemplate) {
|
||||
this.templateMessageConverter = rabbitTemplate.getMessageConverter();
|
||||
}
|
||||
setErrorMessageStrategy(new AmqpMessageHeaderErrorMessageStrategy());
|
||||
this.abstractListenerContainer = listenerContainer instanceof AbstractMessageListenerContainer
|
||||
? (AbstractMessageListenerContainer) listenerContainer
|
||||
this.abstractListenerContainer = listenerContainer instanceof AbstractMessageListenerContainer abstractMessageListenerContainer
|
||||
? abstractMessageListenerContainer
|
||||
: null;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.3
|
||||
*
|
||||
@@ -594,8 +595,8 @@ public abstract class AbstractAmqpOutboundEndpoint extends AbstractReplyProducin
|
||||
}
|
||||
if (correlationData == null) {
|
||||
Object correlation = requestMessage.getHeaders().get(AmqpHeaders.PUBLISH_CONFIRM_CORRELATION);
|
||||
if (correlation instanceof CorrelationData) {
|
||||
correlationData = (CorrelationData) correlation;
|
||||
if (correlation instanceof CorrelationData castCorrelationData) {
|
||||
correlationData = castCorrelationData;
|
||||
}
|
||||
if (correlationData != null) {
|
||||
correlationData = new CorrelationDataWrapper(messageId, correlationData, requestMessage);
|
||||
@@ -728,8 +729,8 @@ public abstract class AbstractAmqpOutboundEndpoint extends AbstractReplyProducin
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Confirm> getFuture() {
|
||||
if (this.userData instanceof CorrelationData) {
|
||||
return ((CorrelationData) this.userData).getFuture();
|
||||
if (this.userData instanceof CorrelationData correlationData) {
|
||||
return correlationData.getFuture();
|
||||
}
|
||||
else {
|
||||
return super.getFuture();
|
||||
@@ -738,8 +739,8 @@ public abstract class AbstractAmqpOutboundEndpoint extends AbstractReplyProducin
|
||||
|
||||
@Override
|
||||
public void setReturned(ReturnedMessage returned) {
|
||||
if (this.userData instanceof CorrelationData) {
|
||||
((CorrelationData) this.userData).setReturned(returned);
|
||||
if (this.userData instanceof CorrelationData correlationData) {
|
||||
correlationData.setReturned(returned);
|
||||
}
|
||||
super.setReturned(returned);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -44,6 +44,7 @@ import org.springframework.util.Assert;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -67,9 +68,9 @@ public class AmqpOutboundEndpoint extends AbstractAmqpOutboundEndpoint
|
||||
public AmqpOutboundEndpoint(AmqpTemplate amqpTemplate) {
|
||||
Assert.notNull(amqpTemplate, "amqpTemplate must not be null");
|
||||
this.amqpTemplate = amqpTemplate;
|
||||
if (amqpTemplate instanceof RabbitTemplate) {
|
||||
setConnectionFactory(((RabbitTemplate) amqpTemplate).getConnectionFactory());
|
||||
this.rabbitTemplate = (RabbitTemplate) amqpTemplate;
|
||||
if (amqpTemplate instanceof RabbitTemplate castRabbitTemplate) {
|
||||
setConnectionFactory(castRabbitTemplate.getConnectionFactory());
|
||||
this.rabbitTemplate = castRabbitTemplate;
|
||||
}
|
||||
else {
|
||||
this.rabbitTemplate = null;
|
||||
@@ -159,8 +160,8 @@ public class AmqpOutboundEndpoint extends AbstractAmqpOutboundEndpoint
|
||||
|
||||
@Override
|
||||
protected void doStop() {
|
||||
if (this.amqpTemplate instanceof Lifecycle) {
|
||||
((Lifecycle) this.amqpTemplate).stop();
|
||||
if (this.amqpTemplate instanceof Lifecycle lifecycle) {
|
||||
lifecycle.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2022-2023 the original author or authors.
|
||||
* Copyright 2022-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.
|
||||
@@ -60,6 +60,7 @@ import org.springframework.util.Assert;
|
||||
* @author Soby Chacko
|
||||
* @author Artem Bilan
|
||||
* @author Filippo Balicchia
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 6.0
|
||||
*/
|
||||
@@ -180,11 +181,11 @@ public class CassandraMessageHandler extends AbstractReplyProducingMessageHandle
|
||||
|
||||
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
|
||||
TypeLocator typeLocator = this.evaluationContext.getTypeLocator();
|
||||
if (typeLocator instanceof StandardTypeLocator) {
|
||||
if (typeLocator instanceof StandardTypeLocator standardTypeLocator) {
|
||||
/*
|
||||
* Register the Cassandra Query DSL package, so they don't need a FQCN for QueryBuilder, for example.
|
||||
*/
|
||||
((StandardTypeLocator) typeLocator).registerImport(QueryBuilder.class.getPackage().getName());
|
||||
standardTypeLocator.registerImport(QueryBuilder.class.getPackage().getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Enrique Rodriguez
|
||||
* @author Meherzad Lahewala
|
||||
* @author Jayadev Sirimamilla
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -387,14 +388,14 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
|
||||
"'discardChannelName' and 'discardChannel' are mutually exclusive.");
|
||||
BeanFactory beanFactory = getBeanFactory();
|
||||
if (beanFactory != null) {
|
||||
if (this.outputProcessor instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.outputProcessor).setBeanFactory(beanFactory);
|
||||
if (this.outputProcessor instanceof BeanFactoryAware beanFactoryAware) {
|
||||
beanFactoryAware.setBeanFactory(beanFactory);
|
||||
}
|
||||
if (this.correlationStrategy instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.correlationStrategy).setBeanFactory(beanFactory);
|
||||
if (this.correlationStrategy instanceof BeanFactoryAware beanFactoryAware) {
|
||||
beanFactoryAware.setBeanFactory(beanFactory);
|
||||
}
|
||||
if (this.releaseStrategy instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.releaseStrategy).setBeanFactory(beanFactory);
|
||||
if (this.releaseStrategy instanceof BeanFactoryAware beanFactoryAware) {
|
||||
beanFactoryAware.setBeanFactory(beanFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -422,8 +423,8 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
|
||||
this.lockRegistrySet = true;
|
||||
this.forceReleaseProcessor = createGroupTimeoutProcessor();
|
||||
|
||||
if (this.releaseStrategy instanceof GroupConditionProvider) {
|
||||
this.groupConditionSupplier = ((GroupConditionProvider) this.releaseStrategy).getGroupConditionSupplier();
|
||||
if (this.releaseStrategy instanceof GroupConditionProvider groupConditionProvider) {
|
||||
this.groupConditionSupplier = groupConditionProvider.getGroupConditionSupplier();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,8 +672,8 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
|
||||
*/
|
||||
if (groupTimeout != null) {
|
||||
Date startTime = null;
|
||||
if (groupTimeout instanceof Date) {
|
||||
startTime = (Date) groupTimeout;
|
||||
if (groupTimeout instanceof Date date) {
|
||||
startTime = date;
|
||||
}
|
||||
else if ((Long) groupTimeout > 0) {
|
||||
startTime = new Date(System.currentTimeMillis() + (Long) groupTimeout);
|
||||
@@ -976,11 +977,11 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
|
||||
public void start() {
|
||||
if (!this.running) {
|
||||
this.running = true;
|
||||
if (this.outputProcessor instanceof Lifecycle) {
|
||||
((Lifecycle) this.outputProcessor).start();
|
||||
if (this.outputProcessor instanceof Lifecycle lifecycle) {
|
||||
lifecycle.start();
|
||||
}
|
||||
if (this.releaseStrategy instanceof Lifecycle) {
|
||||
((Lifecycle) this.releaseStrategy).start();
|
||||
if (this.releaseStrategy instanceof Lifecycle lifecycle) {
|
||||
lifecycle.start();
|
||||
}
|
||||
if (this.expireTimeout > 0) {
|
||||
purgeOrphanedGroups();
|
||||
@@ -996,11 +997,11 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
|
||||
public void stop() {
|
||||
if (this.running) {
|
||||
this.running = false;
|
||||
if (this.outputProcessor instanceof Lifecycle) {
|
||||
((Lifecycle) this.outputProcessor).stop();
|
||||
if (this.outputProcessor instanceof Lifecycle lifecycle) {
|
||||
lifecycle.stop();
|
||||
}
|
||||
if (this.releaseStrategy instanceof Lifecycle) {
|
||||
((Lifecycle) this.releaseStrategy).stop();
|
||||
if (this.releaseStrategy instanceof Lifecycle lifecycle) {
|
||||
lifecycle.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1033,8 +1034,8 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
|
||||
*/
|
||||
super(messageGroup.getMessages(), null, messageGroup.getGroupId(), messageGroup.getTimestamp(),
|
||||
messageGroup.isComplete(), true);
|
||||
if (messageGroup instanceof SimpleMessageGroup) {
|
||||
this.sourceGroup = (SimpleMessageGroup) messageGroup;
|
||||
if (messageGroup instanceof SimpleMessageGroup simpleMessageGroup) {
|
||||
this.sourceGroup = simpleMessageGroup;
|
||||
}
|
||||
else {
|
||||
this.sourceGroup = null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-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 @@ import org.springframework.messaging.Message;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -103,8 +104,8 @@ public class AggregatingMessageHandler extends AbstractCorrelatingMessageHandler
|
||||
remove(messageGroup);
|
||||
}
|
||||
else {
|
||||
if (messageStore instanceof SimpleMessageStore) {
|
||||
((SimpleMessageStore) messageStore).clearMessageGroup(groupId);
|
||||
if (messageStore instanceof SimpleMessageStore simpleMessageStore) {
|
||||
simpleMessageStore.clearMessageGroup(groupId);
|
||||
}
|
||||
else {
|
||||
messageStore.removeMessagesFromGroup(groupId, messageGroup.getMessages());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-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 @@ import org.springframework.messaging.Message;
|
||||
* @author Dave Syer
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -42,7 +43,7 @@ public class ResequencingMessageGroupProcessor implements MessageGroupProcessor
|
||||
public Object processMessageGroup(MessageGroup group) {
|
||||
Collection<Message<?>> messages = group.getMessages();
|
||||
|
||||
if (messages.size() > 0) {
|
||||
if (!messages.isEmpty()) {
|
||||
List<Message<?>> sorted = new ArrayList<>(messages);
|
||||
sorted.sort(this.comparator);
|
||||
ArrayList<Message<?>> partialSequence = new ArrayList<>();
|
||||
|
||||
@@ -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.
|
||||
@@ -47,6 +47,7 @@ import org.springframework.util.CollectionUtils;
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.2
|
||||
*
|
||||
@@ -185,8 +186,7 @@ public abstract class AbstractExecutorChannel extends AbstractSubscribableChanne
|
||||
private Message<?> applyBeforeHandle(Message<?> message, Deque<ExecutorChannelInterceptor> interceptorStack) {
|
||||
Message<?> theMessage = message;
|
||||
for (ChannelInterceptor interceptor : AbstractExecutorChannel.this.interceptors.interceptors) {
|
||||
if (interceptor instanceof ExecutorChannelInterceptor) {
|
||||
ExecutorChannelInterceptor executorInterceptor = (ExecutorChannelInterceptor) interceptor;
|
||||
if (interceptor instanceof ExecutorChannelInterceptor executorInterceptor) {
|
||||
theMessage = executorInterceptor.beforeHandle(theMessage, AbstractExecutorChannel.this,
|
||||
this.delegate.getMessageHandler());
|
||||
if (theMessage == null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2022 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.
|
||||
@@ -35,6 +35,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
@@ -63,7 +64,7 @@ public abstract class AbstractKryoCodec implements Codec {
|
||||
Assert.notNull(outputStream, "'outputSteam' cannot be null");
|
||||
|
||||
Kryo kryo = this.pool.obtain();
|
||||
try (Output output = (outputStream instanceof Output ? (Output) outputStream : new Output(outputStream))) {
|
||||
try (Output output = (outputStream instanceof Output castOutput ? castOutput : new Output(outputStream))) {
|
||||
doEncode(kryo, object, output);
|
||||
}
|
||||
finally {
|
||||
@@ -86,7 +87,7 @@ public abstract class AbstractKryoCodec implements Codec {
|
||||
Assert.notNull(type, "'type' cannot be null");
|
||||
|
||||
Kryo kryo = this.pool.obtain();
|
||||
try (Input input = (inputStream instanceof Input ? (Input) inputStream : new Input(inputStream))) {
|
||||
try (Input input = (inputStream instanceof Input castInput ? castInput : new Input(inputStream))) {
|
||||
return doDecode(kryo, input, type);
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -118,6 +118,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Chris Bono
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation>
|
||||
implements MethodAnnotationPostProcessor<T>, BeanFactoryAware {
|
||||
@@ -447,8 +448,8 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
&& StringUtils.hasText(MessagingAnnotationUtils.endpointIdValue(method))) {
|
||||
handlerBeanName = handlerBeanName + ".wrapper";
|
||||
}
|
||||
if (handler instanceof IntegrationObjectSupport) {
|
||||
((IntegrationObjectSupport) handler).setComponentName(
|
||||
if (handler instanceof IntegrationObjectSupport integrationObjectSupport) {
|
||||
integrationObjectSupport.setComponentName(
|
||||
handlerBeanName.substring(0,
|
||||
handlerBeanName.indexOf(IntegrationConfigUtils.HANDLER_ALIAS_SUFFIX)));
|
||||
}
|
||||
@@ -464,8 +465,8 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
String resolvedValue = this.beanFactory.resolveEmbeddedValue(sendTimeout);
|
||||
if (resolvedValue != null) {
|
||||
long value = Long.parseLong(resolvedValue);
|
||||
if (handler instanceof AbstractMessageProducingHandler) {
|
||||
((AbstractMessageProducingHandler) handler).setSendTimeout(value);
|
||||
if (handler instanceof AbstractMessageProducingHandler abstractMessageProducingHandler) {
|
||||
abstractMessageProducingHandler.setSendTimeout(value);
|
||||
}
|
||||
else {
|
||||
((AbstractMessageRouter) handler).setSendTimeout(value);
|
||||
@@ -490,8 +491,8 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
advisor.setPointcut(pointcut);
|
||||
advisor.setBeanFactory(this.beanFactory);
|
||||
|
||||
if (handler instanceof Advised) {
|
||||
((Advised) handler).addAdvisor(advisor);
|
||||
if (handler instanceof Advised advised) {
|
||||
advised.addAdvisor(advisor);
|
||||
}
|
||||
else {
|
||||
ProxyFactory proxyFactory = new ProxyFactory(handler);
|
||||
@@ -507,8 +508,8 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
MessageHandler handler = handlerArg;
|
||||
List<Advice> adviceChain = extractAdviceChain(beanName, annotations);
|
||||
|
||||
if (!CollectionUtils.isEmpty(adviceChain) && handler instanceof AbstractReplyProducingMessageHandler) {
|
||||
((AbstractReplyProducingMessageHandler) handler).setAdviceChain(adviceChain);
|
||||
if (!CollectionUtils.isEmpty(adviceChain) && handler instanceof AbstractReplyProducingMessageHandler abstractReplyProducingMessageHandler) {
|
||||
abstractReplyProducingMessageHandler.setAdviceChain(adviceChain);
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(adviceChain)) {
|
||||
@@ -516,8 +517,8 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
if (advice instanceof HandleMessageAdvice) {
|
||||
NameMatchMethodPointcutAdvisor handlerAdvice = new NameMatchMethodPointcutAdvisor(advice);
|
||||
handlerAdvice.addMethodName("handleMessage");
|
||||
if (handler instanceof Advised) {
|
||||
((Advised) handler).addAdvisor(handlerAdvice);
|
||||
if (handler instanceof Advised advised) {
|
||||
advised.addAdvisor(handlerAdvice);
|
||||
}
|
||||
else {
|
||||
ProxyFactory proxyFactory = new ProxyFactory(handler);
|
||||
@@ -543,11 +544,11 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
adviceChain = new ArrayList<>();
|
||||
for (String adviceChainName : adviceChainNames) {
|
||||
Object adviceChainBean = this.beanFactory.getBean(adviceChainName);
|
||||
if (adviceChainBean instanceof Advice) {
|
||||
adviceChain.add((Advice) adviceChainBean);
|
||||
if (adviceChainBean instanceof Advice advice) {
|
||||
adviceChain.add(advice);
|
||||
}
|
||||
else if (adviceChainBean instanceof Advice[]) {
|
||||
Collections.addAll(adviceChain, (Advice[]) adviceChainBean);
|
||||
else if (adviceChainBean instanceof Advice[] advices) {
|
||||
Collections.addAll(adviceChain, advices);
|
||||
}
|
||||
else if (adviceChainBean instanceof Collection) {
|
||||
@SuppressWarnings(UNCHECKED)
|
||||
@@ -604,11 +605,11 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
if (inputChannel instanceof Publisher || handler instanceof ReactiveMessageHandlerAdapter || reactive != null) {
|
||||
return reactiveStreamsConsumer(inputChannel, handler, reactive);
|
||||
}
|
||||
else if (inputChannel instanceof SubscribableChannel) {
|
||||
else if (inputChannel instanceof SubscribableChannel subscribableChannel) {
|
||||
Assert.state(poller == null, () ->
|
||||
"A '@Poller' should not be specified for Annotation-based " +
|
||||
"endpoint, since '" + inputChannel + "' is a SubscribableChannel (not pollable).");
|
||||
return new EventDrivenConsumer((SubscribableChannel) inputChannel, handler);
|
||||
return new EventDrivenConsumer(subscribableChannel, handler);
|
||||
}
|
||||
else if (inputChannel instanceof PollableChannel) {
|
||||
return pollingConsumer(inputChannel, handler, poller);
|
||||
@@ -624,9 +625,9 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
Reactive reactive) {
|
||||
|
||||
ReactiveStreamsConsumer reactiveStreamsConsumer;
|
||||
if (handler instanceof ReactiveMessageHandlerAdapter) {
|
||||
if (handler instanceof ReactiveMessageHandlerAdapter reactiveMessageHandlerAdapter) {
|
||||
reactiveStreamsConsumer = new ReactiveStreamsConsumer(channel,
|
||||
((ReactiveMessageHandlerAdapter) handler).getDelegate());
|
||||
reactiveMessageHandlerAdapter.getDelegate());
|
||||
}
|
||||
else {
|
||||
reactiveStreamsConsumer = new ReactiveStreamsConsumer(channel, handler);
|
||||
@@ -696,8 +697,8 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
}
|
||||
pollingEndpoint.setMaxMessagesPerPoll(maxMessagesPerPoll);
|
||||
pollingEndpoint.setErrorHandler(pollerMetadata.getErrorHandler());
|
||||
if (pollingEndpoint instanceof PollingConsumer) {
|
||||
((PollingConsumer) pollingEndpoint).setReceiveTimeout(pollerMetadata.getReceiveTimeout());
|
||||
if (pollingEndpoint instanceof PollingConsumer pollingConsumer) {
|
||||
pollingConsumer.setReceiveTimeout(pollerMetadata.getReceiveTimeout());
|
||||
}
|
||||
pollingEndpoint.setTransactionSynchronizationFactory(pollerMetadata.getTransactionSynchronizationFactory());
|
||||
}
|
||||
@@ -834,10 +835,10 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
}
|
||||
|
||||
private static void orderable(Method method, MessageHandler handler) {
|
||||
if (handler instanceof Orderable) {
|
||||
if (handler instanceof Orderable orderable) {
|
||||
Order orderAnnotation = AnnotationUtils.findAnnotation(method, Order.class);
|
||||
if (orderAnnotation != null) {
|
||||
((Orderable) handler).setOrder(orderAnnotation.value());
|
||||
orderable.setOrder(orderAnnotation.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -61,6 +61,7 @@ import org.springframework.util.CollectionUtils;
|
||||
* @author Artem Bilan
|
||||
* @author David Liu
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractSimpleMessageHandlerFactoryBean<H extends MessageHandler>
|
||||
implements FactoryBean<MessageHandler>, ApplicationContextAware, BeanFactoryAware, BeanNameAware,
|
||||
@@ -251,13 +252,13 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean<H extends MessageH
|
||||
|
||||
private void adviceChain(Object actualHandler) {
|
||||
if (!CollectionUtils.isEmpty(this.adviceChain)) {
|
||||
if (actualHandler instanceof AbstractReplyProducingMessageHandler) {
|
||||
((AbstractReplyProducingMessageHandler) actualHandler).setAdviceChain(this.adviceChain);
|
||||
if (actualHandler instanceof AbstractReplyProducingMessageHandler abstractReplyProducingMessageHandler) {
|
||||
abstractReplyProducingMessageHandler.setAdviceChain(this.adviceChain);
|
||||
}
|
||||
else if (this.logger.isDebugEnabled()) {
|
||||
String name = this.componentName;
|
||||
if (name == null && actualHandler instanceof NamedComponent) {
|
||||
name = ((NamedComponent) actualHandler).getBeanName();
|
||||
if (name == null && actualHandler instanceof NamedComponent namedComponent) {
|
||||
name = namedComponent.getBeanName();
|
||||
}
|
||||
this.logger.debug("adviceChain can only be set on an AbstractReplyProducingMessageHandler"
|
||||
+ (name == null ? "" : (", " + name)) + ".");
|
||||
@@ -266,9 +267,9 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean<H extends MessageH
|
||||
}
|
||||
|
||||
private void initializingBean() {
|
||||
if (this.handler instanceof InitializingBean) {
|
||||
if (this.handler instanceof InitializingBean initializingBean) {
|
||||
try {
|
||||
((InitializingBean) this.handler).afterPropertiesSet();
|
||||
initializingBean.afterPropertiesSet();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new BeanInitializationException("failed to initialize MessageHandler", e);
|
||||
@@ -277,8 +278,7 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean<H extends MessageH
|
||||
}
|
||||
|
||||
private void configureOutputChannelIfAny() {
|
||||
if (this.handler instanceof MessageProducer) {
|
||||
MessageProducer messageProducer = (MessageProducer) this.handler;
|
||||
if (this.handler instanceof MessageProducer messageProducer) {
|
||||
if (this.outputChannel != null) {
|
||||
messageProducer.setOutputChannel(this.outputChannel);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -39,6 +39,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author David Liu
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractStandardMessageHandlerFactoryBean
|
||||
extends AbstractSimpleMessageHandlerFactoryBean<MessageHandler> implements DisposableBean {
|
||||
@@ -207,8 +208,8 @@ public abstract class AbstractStandardMessageHandlerFactoryBean
|
||||
}
|
||||
|
||||
if (this.requiresReply != null) {
|
||||
if (handler instanceof AbstractReplyProducingMessageHandler) {
|
||||
((AbstractReplyProducingMessageHandler) handler).setRequiresReply(this.requiresReply);
|
||||
if (handler instanceof AbstractReplyProducingMessageHandler abstractReplyProducingMessageHandler) {
|
||||
abstractReplyProducingMessageHandler.setRequiresReply(this.requiresReply);
|
||||
}
|
||||
else {
|
||||
if (this.requiresReply && logger.isDebugEnabled()) {
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.2
|
||||
*
|
||||
@@ -197,8 +198,8 @@ public class AggregatorFactoryBean extends AbstractSimpleMessageHandlerFactoryBe
|
||||
@Override
|
||||
protected AggregatingMessageHandler createHandler() {
|
||||
MessageGroupProcessor outputProcessor;
|
||||
if (this.processorBean instanceof MessageGroupProcessor) {
|
||||
outputProcessor = (MessageGroupProcessor) this.processorBean;
|
||||
if (this.processorBean instanceof MessageGroupProcessor messageGroupProcessor) {
|
||||
outputProcessor = messageGroupProcessor;
|
||||
}
|
||||
else {
|
||||
if (!StringUtils.hasText(this.methodName)) {
|
||||
@@ -210,8 +211,8 @@ public class AggregatorFactoryBean extends AbstractSimpleMessageHandlerFactoryBe
|
||||
}
|
||||
|
||||
if (this.headersFunction != null) {
|
||||
if (outputProcessor instanceof AbstractAggregatingMessageGroupProcessor) {
|
||||
((AbstractAggregatingMessageGroupProcessor) outputProcessor).setHeadersFunction(this.headersFunction);
|
||||
if (outputProcessor instanceof AbstractAggregatingMessageGroupProcessor abstractAggregatingMessageGroupProcessor) {
|
||||
abstractAggregatingMessageGroupProcessor.setHeadersFunction(this.headersFunction);
|
||||
}
|
||||
else {
|
||||
outputProcessor = new DelegatingMessageGroupProcessor(outputProcessor, this.headersFunction);
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.springframework.util.Assert;
|
||||
* Used to post process candidates for {@link FixedSubscriberChannel}
|
||||
* {@link org.springframework.messaging.MessageHandler}s.
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
* @since 4.0
|
||||
*
|
||||
*/
|
||||
@@ -47,7 +48,7 @@ public final class FixedSubscriberChannelBeanFactoryPostProcessor implements Bea
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
if (beanFactory instanceof BeanDefinitionRegistry) {
|
||||
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
|
||||
if (this.candidateFixedChannelHandlerMap.size() > 0) {
|
||||
if (!this.candidateFixedChannelHandlerMap.isEmpty()) {
|
||||
for (Entry<String, String> entry : this.candidateFixedChannelHandlerMap.entrySet()) {
|
||||
String handlerName = entry.getKey();
|
||||
String channelName = entry.getValue();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -33,6 +33,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Gary Russell
|
||||
* @author David Liu
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class TransformerFactoryBean extends AbstractStandardMessageHandlerFactoryBean {
|
||||
|
||||
@@ -44,8 +45,8 @@ public class TransformerFactoryBean extends AbstractStandardMessageHandlerFactor
|
||||
protected MessageHandler createMethodInvokingHandler(Object targetObject, String targetMethodName) {
|
||||
Assert.notNull(targetObject, "targetObject must not be null");
|
||||
Transformer transformer = null;
|
||||
if (targetObject instanceof Transformer) {
|
||||
transformer = (Transformer) targetObject;
|
||||
if (targetObject instanceof Transformer castTransformer) {
|
||||
transformer = castTransformer;
|
||||
}
|
||||
else {
|
||||
this.checkForIllegalTarget(targetObject, targetMethodName);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -42,6 +42,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractOutboundChannelAdapterParser extends AbstractChannelAdapterParser {
|
||||
|
||||
@@ -99,8 +100,7 @@ public abstract class AbstractOutboundChannelAdapterParser extends AbstractChann
|
||||
boolean isReplyProducer = this.isUsingReplyProducer();
|
||||
if (!isReplyProducer) {
|
||||
Class<?> beanClass = null;
|
||||
if (handlerBeanDefinition instanceof AbstractBeanDefinition) {
|
||||
AbstractBeanDefinition abstractBeanDefinition = (AbstractBeanDefinition) handlerBeanDefinition;
|
||||
if (handlerBeanDefinition instanceof AbstractBeanDefinition abstractBeanDefinition) {
|
||||
if (abstractBeanDefinition.hasBeanClass()) {
|
||||
beanClass = abstractBeanDefinition.getBeanClass();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -34,6 +34,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
* @author Gary Russell
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractPollingInboundChannelAdapterParser extends AbstractChannelAdapterParser {
|
||||
|
||||
@@ -48,13 +49,13 @@ public abstract class AbstractPollingInboundChannelAdapterParser extends Abstrac
|
||||
|
||||
String sourceBeanName = null;
|
||||
|
||||
if (source instanceof BeanDefinition) {
|
||||
if (source instanceof BeanDefinition beanDefinition) {
|
||||
String channelAdapterId = this.resolveId(element, adapterBuilder.getRawBeanDefinition(), parserContext);
|
||||
sourceBeanName = channelAdapterId + ".source";
|
||||
parserContext.getRegistry().registerBeanDefinition(sourceBeanName, (BeanDefinition) source);
|
||||
parserContext.getRegistry().registerBeanDefinition(sourceBeanName, beanDefinition);
|
||||
}
|
||||
else if (source instanceof RuntimeBeanReference) {
|
||||
sourceBeanName = ((RuntimeBeanReference) source).getBeanName();
|
||||
else if (source instanceof RuntimeBeanReference runtimeBeanReference) {
|
||||
sourceBeanName = runtimeBeanReference.getBeanName();
|
||||
}
|
||||
else {
|
||||
parserContext.getReaderContext().error("Wrong 'source' type: must be 'BeanDefinition' or 'RuntimeBeanReference'", source);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -34,6 +34,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractRouterParser extends AbstractConsumerEndpointParser {
|
||||
|
||||
@@ -61,7 +62,7 @@ public abstract class AbstractRouterParser extends AbstractConsumerEndpointParse
|
||||
// check if mapping is provided otherwise returned values will be treated as channel names
|
||||
List<Element> mappingElements = DomUtils.getChildElementsByTagName(element, "mapping");
|
||||
if (!CollectionUtils.isEmpty(mappingElements)) {
|
||||
ManagedMap<String, String> channelMappings = new ManagedMap<String, String>();
|
||||
ManagedMap<String, String> channelMappings = new ManagedMap<>();
|
||||
for (Element mappingElement : mappingElements) {
|
||||
String key = mappingElement.getAttribute(this.getMappingKeyAttributeName());
|
||||
channelMappings.put(key, mappingElement.getAttribute("channel"));
|
||||
|
||||
@@ -51,6 +51,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
* @author Artem Bilan
|
||||
* @author Gunnar Hillert
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class ChainParser extends AbstractConsumerEndpointParser {
|
||||
|
||||
@@ -73,8 +74,8 @@ public class ChainParser extends AbstractConsumerEndpointParser {
|
||||
}
|
||||
|
||||
String chainHandlerId = this.resolveId(element, builder.getRawBeanDefinition(), parserContext);
|
||||
List<BeanMetadataElement> handlerList = new ManagedList<BeanMetadataElement>();
|
||||
Set<String> handlerBeanNameSet = new HashSet<String>();
|
||||
List<BeanMetadataElement> handlerList = new ManagedList<>();
|
||||
Set<String> handlerBeanNameSet = new HashSet<>();
|
||||
NodeList children = element.getChildNodes();
|
||||
|
||||
int childOrder = 0;
|
||||
@@ -83,8 +84,8 @@ public class ChainParser extends AbstractConsumerEndpointParser {
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE && !"poller".equals(child.getLocalName())) {
|
||||
BeanMetadataElement childBeanMetadata = this.parseChild(chainHandlerId, (Element) child, childOrder++,
|
||||
parserContext, builder.getBeanDefinition());
|
||||
if (childBeanMetadata instanceof RuntimeBeanReference) {
|
||||
String handlerBeanName = ((RuntimeBeanReference) childBeanMetadata).getBeanName();
|
||||
if (childBeanMetadata instanceof RuntimeBeanReference runtimeBeanReference) {
|
||||
String handlerBeanName = runtimeBeanReference.getBeanName();
|
||||
if (!handlerBeanNameSet.add(handlerBeanName)) {
|
||||
parserContext.getReaderContext().error("A bean definition is already registered for " +
|
||||
"beanName: '" + handlerBeanName + "' within the current <chain>.",
|
||||
|
||||
@@ -37,13 +37,14 @@ import org.springframework.beans.factory.xml.ParserContext;
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class ChannelInterceptorParser {
|
||||
|
||||
private final Map<String, BeanDefinitionRegisteringParser> parsers;
|
||||
|
||||
public ChannelInterceptorParser() {
|
||||
this.parsers = new HashMap<String, BeanDefinitionRegisteringParser>();
|
||||
this.parsers = new HashMap<>();
|
||||
this.parsers.put("wire-tap", new WireTapParser());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -43,6 +43,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
* @author Liujiong
|
||||
* @author Kris Jacyna
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
* @since 2.1
|
||||
*/
|
||||
public class EnricherParser extends AbstractConsumerEndpointParser {
|
||||
@@ -107,10 +108,10 @@ public class EnricherParser extends AbstractConsumerEndpointParser {
|
||||
nullResultExpression, hasAttributeValue, hasAttributeExpression,
|
||||
hasAttributeNullResultExpression);
|
||||
}
|
||||
if (expressions.size() > 0) {
|
||||
if (!expressions.isEmpty()) {
|
||||
builder.addPropertyValue("propertyExpressions", expressions);
|
||||
}
|
||||
if (nullResultExpressions.size() > 0) {
|
||||
if (!nullResultExpressions.isEmpty()) {
|
||||
builder.addPropertyValue("nullResultPropertyExpressions", nullResultExpressions);
|
||||
}
|
||||
}
|
||||
@@ -183,10 +184,10 @@ public class EnricherParser extends AbstractConsumerEndpointParser {
|
||||
headerExpression(parserContext, expressions, nullResultHeaderExpressions, subElement, name,
|
||||
valueElementValue, hasAttributeValue, hasAttributeExpression, hasAttributeNullResultExpression);
|
||||
}
|
||||
if (expressions.size() > 0) {
|
||||
if (!expressions.isEmpty()) {
|
||||
builder.addPropertyValue("headerExpressions", expressions);
|
||||
}
|
||||
if (nullResultHeaderExpressions.size() > 0) {
|
||||
if (!nullResultHeaderExpressions.isEmpty()) {
|
||||
builder.addPropertyValue("nullResultHeaderExpressions", nullResultHeaderExpressions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -42,6 +42,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
* @since 2.0
|
||||
*/
|
||||
public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
|
||||
@@ -89,7 +90,7 @@ public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
|
||||
|
||||
// set headersMap
|
||||
Map<String, String> headerExpressions = headerExpressions(parserContext, mapping);
|
||||
if (headerExpressions.size() > 0) {
|
||||
if (!headerExpressions.isEmpty()) {
|
||||
headersExpressionMap.put(methodPattern, headerExpressions);
|
||||
}
|
||||
|
||||
@@ -100,14 +101,14 @@ public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
|
||||
resolvableChannelMap.put(channel, new RuntimeBeanReference(channel));
|
||||
}
|
||||
}
|
||||
if (payloadExpressionMap.size() == 0) {
|
||||
if (payloadExpressionMap.isEmpty()) {
|
||||
payloadExpressionMap.put("*", "#return");
|
||||
}
|
||||
interceptorMappings.put(PAYLOAD, payloadExpressionMap);
|
||||
if (headersExpressionMap.size() > 0) {
|
||||
if (!headersExpressionMap.isEmpty()) {
|
||||
interceptorMappings.put("headers", headersExpressionMap);
|
||||
}
|
||||
if (channelMap.size() > 0) {
|
||||
if (!channelMap.isEmpty()) {
|
||||
interceptorMappings.put("channels", channelMap);
|
||||
interceptorMappings.put("resolvableChannels", resolvableChannelMap);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
*
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Mark Fisher
|
||||
* @author Ngoc Nhan
|
||||
* @since 1.0.3
|
||||
*/
|
||||
public class RecipientListRouterParser extends AbstractRouterParser {
|
||||
@@ -58,7 +59,7 @@ public class RecipientListRouterParser extends AbstractRouterParser {
|
||||
}
|
||||
recipientList.add(recipientBuilder.getBeanDefinition());
|
||||
}
|
||||
if (recipientList.size() > 0) {
|
||||
if (!recipientList.isEmpty()) {
|
||||
recipientListRouterBuilder.addPropertyValue("recipients", recipientList);
|
||||
}
|
||||
return recipientListRouterBuilder.getBeanDefinition();
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.util.Assert;
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
* @since 2.0
|
||||
*/
|
||||
public class AsyncMessagingTemplate extends MessagingTemplate implements AsyncMessagingOperations {
|
||||
@@ -41,8 +42,8 @@ public class AsyncMessagingTemplate extends MessagingTemplate implements AsyncMe
|
||||
|
||||
public void setExecutor(Executor executor) {
|
||||
Assert.notNull(executor, "executor must not be null");
|
||||
this.executor = (executor instanceof AsyncTaskExecutor) ?
|
||||
(AsyncTaskExecutor) executor : new TaskExecutorAdapter(executor);
|
||||
this.executor = (executor instanceof AsyncTaskExecutor asyncTaskExecutor) ?
|
||||
asyncTaskExecutor : new TaskExecutorAdapter(executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.lang.Nullable;
|
||||
* A {@link CorrelationHandlerSpec} for an {@link AggregatingMessageHandler}.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
@@ -71,8 +72,8 @@ public class AggregatorSpec extends CorrelationHandlerSpec<AggregatorSpec, Aggre
|
||||
.outputProcessor(methodName != null
|
||||
? new MethodInvokingMessageGroupProcessor(target, methodName)
|
||||
:
|
||||
(target instanceof MessageGroupProcessor
|
||||
? (MessageGroupProcessor) target
|
||||
(target instanceof MessageGroupProcessor messageGroupProcessor
|
||||
? messageGroupProcessor
|
||||
: new MethodInvokingMessageGroupProcessor(target)));
|
||||
}
|
||||
|
||||
@@ -124,8 +125,8 @@ public class AggregatorSpec extends CorrelationHandlerSpec<AggregatorSpec, Aggre
|
||||
public Map<Object, String> getComponentsToRegister() {
|
||||
if (this.headersFunction != null) {
|
||||
MessageGroupProcessor outputProcessor = this.handler.getOutputProcessor();
|
||||
if (outputProcessor instanceof AbstractAggregatingMessageGroupProcessor) {
|
||||
((AbstractAggregatingMessageGroupProcessor) outputProcessor).setHeadersFunction(this.headersFunction);
|
||||
if (outputProcessor instanceof AbstractAggregatingMessageGroupProcessor abstractAggregatingMessageGroupProcessor) {
|
||||
abstractAggregatingMessageGroupProcessor.setHeadersFunction(this.headersFunction);
|
||||
}
|
||||
else {
|
||||
this.handler.setOutputProcessor(
|
||||
|
||||
@@ -111,6 +111,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Gary Russell
|
||||
* @author Gabriele Del Prete
|
||||
* @author Tim Feuerbach
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 5.2.1
|
||||
*
|
||||
@@ -728,7 +729,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
|
||||
@Nullable Consumer<GenericEndpointSpec<MessageTransformingHandler>> endpointConfigurer) {
|
||||
|
||||
Assert.notNull(genericTransformer, "'genericTransformer' must not be null");
|
||||
Transformer transformer = genericTransformer instanceof Transformer ? (Transformer) genericTransformer :
|
||||
Transformer transformer = genericTransformer instanceof Transformer castTransformer ? castTransformer :
|
||||
(ClassUtils.isLambda(genericTransformer.getClass())
|
||||
? new MethodInvokingTransformer(new LambdaMessageProcessor(genericTransformer, expectedType))
|
||||
: new MethodInvokingTransformer(genericTransformer, ClassUtils.TRANSFORMER_TRANSFORM_METHOD));
|
||||
@@ -900,7 +901,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
|
||||
@Nullable Consumer<FilterEndpointSpec> endpointConfigurer) {
|
||||
|
||||
Assert.notNull(genericSelector, "'genericSelector' must not be null");
|
||||
MessageSelector selector = genericSelector instanceof MessageSelector ? (MessageSelector) genericSelector :
|
||||
MessageSelector selector = genericSelector instanceof MessageSelector messageSelector ? messageSelector :
|
||||
(ClassUtils.isLambda(genericSelector.getClass())
|
||||
? new MethodInvokingSelector(new LambdaMessageProcessor(genericSelector, expectedType))
|
||||
: new MethodInvokingSelector(genericSelector, ClassUtils.SELECTOR_ACCEPT_METHOD));
|
||||
@@ -1136,8 +1137,8 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
|
||||
@Nullable Consumer<GenericEndpointSpec<H>> endpointConfigurer) {
|
||||
|
||||
Assert.notNull(messageHandlerSpec, "'messageHandlerSpec' must not be null");
|
||||
if (messageHandlerSpec instanceof ComponentsRegistration) {
|
||||
addComponents(((ComponentsRegistration) messageHandlerSpec).getComponentsToRegister());
|
||||
if (messageHandlerSpec instanceof ComponentsRegistration componentsRegistration) {
|
||||
addComponents(componentsRegistration.getComponentsToRegister());
|
||||
}
|
||||
return handle(messageHandlerSpec.getObject(), endpointConfigurer);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2023-2023 the original author or authors.
|
||||
* Copyright 2023-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,6 +38,7 @@ import org.springframework.util.Assert;
|
||||
* {@link #processor(MessageProcessorSpec)} or {@link #transformer(GenericTransformer)} must be provided.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 6.2
|
||||
*/
|
||||
@@ -218,7 +219,7 @@ public class TransformerEndpointSpec extends ConsumerEndpointSpec<TransformerEnd
|
||||
}
|
||||
|
||||
private Transformer wrapToTransformerIfAny() {
|
||||
return this.transformer instanceof Transformer ? (Transformer) this.transformer :
|
||||
return this.transformer instanceof Transformer castTransformer ? castTransformer :
|
||||
(ClassUtils.isLambda(this.transformer)
|
||||
? new MethodInvokingTransformer(new LambdaMessageProcessor(this.transformer, this.expectedType))
|
||||
: new MethodInvokingTransformer(this.transformer, ClassUtils.TRANSFORMER_TRANSFORM_METHOD));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -81,6 +81,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Artem Bilan
|
||||
* @author Andreas Baer
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractPollingEndpoint extends AbstractEndpoint implements BeanClassLoaderAware {
|
||||
|
||||
@@ -187,8 +188,8 @@ public abstract class AbstractPollingEndpoint extends AbstractEndpoint implement
|
||||
* @since 4.3
|
||||
*/
|
||||
public MessageChannel getDefaultErrorChannel() {
|
||||
if (!this.errorHandlerIsDefault && this.errorHandler instanceof MessagePublishingErrorHandler) {
|
||||
return ((MessagePublishingErrorHandler) this.errorHandler).getDefaultErrorChannel();
|
||||
if (!this.errorHandlerIsDefault && this.errorHandler instanceof MessagePublishingErrorHandler messagePublishingErrorHandler) {
|
||||
return messagePublishingErrorHandler.getDefaultErrorChannel();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractMessageProcessingSelector
|
||||
implements MessageSelector, BeanFactoryAware, ManageableLifecycle {
|
||||
@@ -53,8 +54,8 @@ public abstract class AbstractMessageProcessingSelector
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
if (this.messageProcessor instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.messageProcessor).setBeanFactory(beanFactory);
|
||||
if (this.messageProcessor instanceof BeanFactoryAware beanFactoryAware) {
|
||||
beanFactoryAware.setBeanFactory(beanFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,21 +73,21 @@ public abstract class AbstractMessageProcessingSelector
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (this.messageProcessor instanceof Lifecycle) {
|
||||
((Lifecycle) this.messageProcessor).start();
|
||||
if (this.messageProcessor instanceof Lifecycle lifecycle) {
|
||||
lifecycle.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if (this.messageProcessor instanceof Lifecycle) {
|
||||
((Lifecycle) this.messageProcessor).stop();
|
||||
if (this.messageProcessor instanceof Lifecycle lifecycle) {
|
||||
lifecycle.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return !(this.messageProcessor instanceof Lifecycle) || ((Lifecycle) this.messageProcessor).isRunning();
|
||||
return !(this.messageProcessor instanceof Lifecycle lifecycle) || lifecycle.isRunning();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Marius Bogoevici
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* since 4.1
|
||||
*/
|
||||
@@ -462,8 +463,8 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan
|
||||
Object path = routingSlip.get(routingSlipIndex.get());
|
||||
Object routingSlipPathValue = null;
|
||||
|
||||
if (path instanceof String) {
|
||||
routingSlipPathValue = getBeanFactory().getBean((String) path);
|
||||
if (path instanceof String string) {
|
||||
routingSlipPathValue = getBeanFactory().getBean(string);
|
||||
}
|
||||
else if (path instanceof RoutingSlipRouteStrategy) {
|
||||
routingSlipPathValue = path;
|
||||
@@ -479,7 +480,7 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan
|
||||
}
|
||||
else {
|
||||
Object nextPath = ((RoutingSlipRouteStrategy) routingSlipPathValue).getNextPath(requestMessage, reply);
|
||||
if (nextPath != null && (!(nextPath instanceof String) || StringUtils.hasText((String) nextPath))) {
|
||||
if (nextPath != null && (!(nextPath instanceof String string) || StringUtils.hasText(string))) {
|
||||
return nextPath;
|
||||
}
|
||||
else {
|
||||
@@ -540,20 +541,20 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan
|
||||
throw new DestinationResolutionException("no output-channel or replyChannel header available");
|
||||
}
|
||||
|
||||
if (replyChannel instanceof MessageChannel) {
|
||||
if (replyChannel instanceof MessageChannel messageChannel) {
|
||||
if (output instanceof Message<?>) {
|
||||
this.messagingTemplate.send((MessageChannel) replyChannel, (Message<?>) output);
|
||||
this.messagingTemplate.send(messageChannel, (Message<?>) output);
|
||||
}
|
||||
else {
|
||||
this.messagingTemplate.convertAndSend((MessageChannel) replyChannel, output);
|
||||
this.messagingTemplate.convertAndSend(messageChannel, output);
|
||||
}
|
||||
}
|
||||
else if (replyChannel instanceof String) {
|
||||
else if (replyChannel instanceof String string) {
|
||||
if (output instanceof Message<?>) {
|
||||
this.messagingTemplate.send((String) replyChannel, (Message<?>) output);
|
||||
this.messagingTemplate.send(string, (Message<?>) output);
|
||||
}
|
||||
else {
|
||||
this.messagingTemplate.convertAndSend((String) replyChannel, output);
|
||||
this.messagingTemplate.convertAndSend(string, output);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.springframework.util.ClassUtils;
|
||||
* @author David Liu
|
||||
* @author Trung Pham
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractReplyProducingMessageHandler extends AbstractMessageProducingHandler
|
||||
implements BeanClassLoaderAware {
|
||||
@@ -91,7 +92,7 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
|
||||
}
|
||||
|
||||
protected boolean hasAdviceChain() {
|
||||
return this.adviceChain.size() > 0;
|
||||
return !this.adviceChain.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,6 +46,7 @@ import org.springframework.util.CollectionUtils;
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
@@ -136,8 +137,8 @@ public class ExpressionCommandMessageProcessor extends AbstractMessageProcessor<
|
||||
}
|
||||
}
|
||||
List<Method> supportedMethods = this.methodFilter.filter(candidates);
|
||||
if (supportedMethods.size() == 0) {
|
||||
String methodDescription = (candidates.size() > 0) ? candidates.get(0).toString() : name;
|
||||
if (supportedMethods.isEmpty()) {
|
||||
String methodDescription = (!candidates.isEmpty()) ? candidates.get(0).toString() : name;
|
||||
throw new EvaluationException("The method '" + methodDescription +
|
||||
"' is not supported by this command processor. " +
|
||||
"If using the Control Bus, consider adding @ManagedOperation or @ManagedAttribute.");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -36,6 +36,7 @@ import org.springframework.messaging.MessagingException;
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
* @since 2.2
|
||||
*/
|
||||
public abstract class AbstractRequestHandlerAdvice extends IntegrationObjectSupport
|
||||
@@ -162,8 +163,8 @@ public abstract class AbstractRequestHandlerAdvice extends IntegrationObjectSupp
|
||||
* If we don't copy the invocation carefully it won't keep a reference to the other
|
||||
* interceptors in the chain.
|
||||
*/
|
||||
if (this.invocation instanceof ProxyMethodInvocation) {
|
||||
return ((ProxyMethodInvocation) this.invocation).invocableClone().proceed();
|
||||
if (this.invocation instanceof ProxyMethodInvocation proxyMethodInvocation) {
|
||||
return proxyMethodInvocation.invocableClone().proceed();
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException(
|
||||
|
||||
@@ -53,6 +53,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* The default cache {@code key} is {@code payload} of the request message.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 5.2
|
||||
*
|
||||
@@ -198,8 +199,7 @@ public class CacheRequestHandlerAdvice extends AbstractRequestHandlerAdvice
|
||||
.filter((operation) -> ObjectUtils.isEmpty(operation.getCacheNames()))
|
||||
.map((operation) -> {
|
||||
CacheOperation.Builder builder;
|
||||
if (operation instanceof CacheableOperation) {
|
||||
CacheableOperation cacheableOperation = (CacheableOperation) operation;
|
||||
if (operation instanceof CacheableOperation cacheableOperation) {
|
||||
CacheableOperation.Builder cacheableBuilder = new CacheableOperation.Builder();
|
||||
cacheableBuilder.setSync(cacheableOperation.isSync());
|
||||
String unless = cacheableOperation.getUnless();
|
||||
@@ -208,9 +208,8 @@ public class CacheRequestHandlerAdvice extends AbstractRequestHandlerAdvice
|
||||
}
|
||||
builder = cacheableBuilder;
|
||||
}
|
||||
else if (operation instanceof CacheEvictOperation) {
|
||||
else if (operation instanceof CacheEvictOperation cacheEvictOperation) {
|
||||
CacheEvictOperation.Builder cacheEvictBuilder = new CacheEvictOperation.Builder();
|
||||
CacheEvictOperation cacheEvictOperation = (CacheEvictOperation) operation;
|
||||
cacheEvictBuilder.setBeforeInvocation(cacheEvictOperation.isBeforeInvocation());
|
||||
cacheEvictBuilder.setCacheWide(cacheEvictOperation.isCacheWide());
|
||||
builder = cacheEvictBuilder;
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Trung Pham
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -372,25 +373,25 @@ public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter
|
||||
|
||||
private void addChannelKeyToCollection(Collection<MessageChannel> channels, Message<?> message, Object channelKey) {
|
||||
ConversionService conversionService = getRequiredConversionService();
|
||||
if (channelKey instanceof MessageChannel) {
|
||||
channels.add((MessageChannel) channelKey);
|
||||
if (channelKey instanceof MessageChannel messageChannel) {
|
||||
channels.add(messageChannel);
|
||||
}
|
||||
else if (channelKey instanceof MessageChannel[]) {
|
||||
channels.addAll(Arrays.asList((MessageChannel[]) channelKey));
|
||||
else if (channelKey instanceof MessageChannel[] messageChannels) {
|
||||
channels.addAll(Arrays.asList(messageChannels));
|
||||
}
|
||||
else if (channelKey instanceof String) {
|
||||
addChannelFromString(channels, (String) channelKey, message);
|
||||
else if (channelKey instanceof String string) {
|
||||
addChannelFromString(channels, string, message);
|
||||
}
|
||||
else if (channelKey instanceof Class) {
|
||||
addChannelFromString(channels, ((Class<?>) channelKey).getName(), message);
|
||||
else if (channelKey instanceof Class<?> cls) {
|
||||
addChannelFromString(channels, cls.getName(), message);
|
||||
}
|
||||
else if (channelKey instanceof String[]) {
|
||||
for (String indicatorName : (String[]) channelKey) {
|
||||
else if (channelKey instanceof String[] strings) {
|
||||
for (String indicatorName : strings) {
|
||||
addChannelFromString(channels, indicatorName, message);
|
||||
}
|
||||
}
|
||||
else if (channelKey instanceof Collection) {
|
||||
addToCollection(channels, (Collection<?>) channelKey, message);
|
||||
else if (channelKey instanceof Collection<?> collection) {
|
||||
addToCollection(channels, collection, message);
|
||||
}
|
||||
else if (conversionService.canConvert(channelKey.getClass(), String.class)) {
|
||||
String converted = conversionService.convert(channelKey, String.class);
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.util.Assert;
|
||||
* {@link MessageProcessor} instance.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Ngoc Nhan
|
||||
* @since 2.0
|
||||
*/
|
||||
class AbstractMessageProcessingRouter extends AbstractMappingMessageRouter
|
||||
@@ -54,28 +55,28 @@ class AbstractMessageProcessingRouter extends AbstractMappingMessageRouter
|
||||
((AbstractMessageProcessor<?>) this.messageProcessor).setConversionService(conversionService);
|
||||
}
|
||||
}
|
||||
if (this.messageProcessor instanceof BeanFactoryAware && this.getBeanFactory() != null) {
|
||||
((BeanFactoryAware) this.messageProcessor).setBeanFactory(this.getBeanFactory());
|
||||
if (this.messageProcessor instanceof BeanFactoryAware beanFactoryAware && this.getBeanFactory() != null) {
|
||||
beanFactoryAware.setBeanFactory(this.getBeanFactory());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (this.messageProcessor instanceof Lifecycle) {
|
||||
((Lifecycle) this.messageProcessor).start();
|
||||
if (this.messageProcessor instanceof Lifecycle lifecycle) {
|
||||
lifecycle.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if (this.messageProcessor instanceof Lifecycle) {
|
||||
((Lifecycle) this.messageProcessor).stop();
|
||||
if (this.messageProcessor instanceof Lifecycle lifecycle) {
|
||||
lifecycle.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return !(this.messageProcessor instanceof Lifecycle) || ((Lifecycle) this.messageProcessor).isRunning();
|
||||
return !(this.messageProcessor instanceof Lifecycle lifecycle) || lifecycle.isRunning();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -67,7 +68,7 @@ abstract class AbstractMessageProcessingSplitter extends AbstractMessageSplitter
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return !(this.processor instanceof Lifecycle) || ((Lifecycle) this.processor).isRunning();
|
||||
return !(this.processor instanceof Lifecycle lifecycle) || lifecycle.isRunning();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Artem Bilan
|
||||
* @author Ruslan Stelmachenko
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractMessageSplitter extends AbstractReplyProducingMessageHandler
|
||||
implements DiscardingMessageHandler {
|
||||
@@ -223,7 +224,7 @@ public abstract class AbstractMessageSplitter extends AbstractReplyProducingMess
|
||||
Function<Object, ?> messageBuilderFunction = prepareMessageBuilderFunction(message, sequenceSize);
|
||||
|
||||
return new FunctionIterator<>(
|
||||
result instanceof AutoCloseable && !result.equals(iterator) ? (AutoCloseable) result : null,
|
||||
result instanceof AutoCloseable autoCloseable && !result.equals(iterator) ? autoCloseable : null,
|
||||
iterator, messageBuilderFunction);
|
||||
}
|
||||
|
||||
@@ -314,17 +315,16 @@ public abstract class AbstractMessageSplitter extends AbstractReplyProducingMess
|
||||
|
||||
@Override
|
||||
protected void produceOutput(Object result, Message<?> requestMessage) {
|
||||
if (result instanceof Iterator<?>) {
|
||||
Iterator<?> iterator = (Iterator<?>) result;
|
||||
if (result instanceof Iterator<?> iterator) {
|
||||
try {
|
||||
while (iterator.hasNext()) {
|
||||
super.produceOutput(iterator.next(), requestMessage);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (iterator instanceof AutoCloseable) {
|
||||
if (iterator instanceof AutoCloseable autoCloseable) {
|
||||
try {
|
||||
((AutoCloseable) iterator).close();
|
||||
autoCloseable.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
// ignored
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.util.Assert;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -107,11 +108,11 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
|
||||
}
|
||||
|
||||
private Message<?> extractMessage(Object object) {
|
||||
if (object instanceof MessageHolder) {
|
||||
return ((MessageHolder) object).getMessage();
|
||||
if (object instanceof MessageHolder messageHolder) {
|
||||
return messageHolder.getMessage();
|
||||
}
|
||||
else if (object instanceof Message) {
|
||||
return (Message<?>) object;
|
||||
else if (object instanceof Message<?> message) {
|
||||
return message;
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException(
|
||||
@@ -126,8 +127,8 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
|
||||
Object object = doRetrieve(this.messagePrefix + messageId);
|
||||
if (object != null) {
|
||||
extractMessage(object);
|
||||
if (object instanceof MessageHolder) {
|
||||
return ((MessageHolder) object).getMessageMetadata();
|
||||
if (object instanceof MessageHolder messageHolder) {
|
||||
return messageHolder.getMessageMetadata();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -33,6 +33,7 @@ import org.springframework.util.Assert;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Laszlo Szabo
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -91,7 +92,7 @@ public class MessageGroupMetadata implements Serializable {
|
||||
}
|
||||
|
||||
public UUID firstId() {
|
||||
if (this.messageIds.size() > 0) {
|
||||
if (!this.messageIds.isEmpty()) {
|
||||
return this.messageIds.get(0);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2023 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.
|
||||
@@ -55,6 +55,7 @@ import org.springframework.util.MultiValueMap;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.2
|
||||
*
|
||||
@@ -169,7 +170,7 @@ public class SmartLifecycleRoleController implements ApplicationListener<Abstrac
|
||||
* @param role the role.
|
||||
*/
|
||||
public void startLifecyclesInRole(String role) {
|
||||
if (this.lazyLifecycles.size() > 0) {
|
||||
if (!this.lazyLifecycles.isEmpty()) {
|
||||
addLazyLifecycles();
|
||||
}
|
||||
List<SmartLifecycle> componentsInRole = this.lifecycles.get(role);
|
||||
@@ -201,7 +202,7 @@ public class SmartLifecycleRoleController implements ApplicationListener<Abstrac
|
||||
* @param role the role.
|
||||
*/
|
||||
public void stopLifecyclesInRole(String role) {
|
||||
if (this.lazyLifecycles.size() > 0) {
|
||||
if (!this.lazyLifecycles.isEmpty()) {
|
||||
addLazyLifecycles();
|
||||
}
|
||||
List<SmartLifecycle> componentsInRole = this.lifecycles.get(role);
|
||||
@@ -234,7 +235,7 @@ public class SmartLifecycleRoleController implements ApplicationListener<Abstrac
|
||||
* @since 4.3.8
|
||||
*/
|
||||
public Collection<String> getRoles() {
|
||||
if (this.lazyLifecycles.size() > 0) {
|
||||
if (!this.lazyLifecycles.isEmpty()) {
|
||||
addLazyLifecycles();
|
||||
}
|
||||
return Collections.unmodifiableCollection(this.lifecycles.keySet());
|
||||
@@ -270,7 +271,7 @@ public class SmartLifecycleRoleController implements ApplicationListener<Abstrac
|
||||
* @since 4.3.8
|
||||
*/
|
||||
public Map<String, Boolean> getEndpointsRunningStatus(String role) {
|
||||
if (this.lazyLifecycles.size() > 0) {
|
||||
if (!this.lazyLifecycles.isEmpty()) {
|
||||
addLazyLifecycles();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-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 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
@@ -43,7 +44,7 @@ public abstract class AbstractJsonInboundMessageMapper<P> implements InboundMess
|
||||
"JSON message is invalid. Expected a message in the format of either " +
|
||||
"{\"headers\":{...},\"payload\":{...}} or {\"payload\":{...}.\"headers\":{...}} but was ";
|
||||
|
||||
protected static final Map<String, Class<?>> DEFAULT_HEADER_TYPES = new HashMap<String, Class<?>>();
|
||||
protected static final Map<String, Class<?>> DEFAULT_HEADER_TYPES = new HashMap<>();
|
||||
|
||||
static {
|
||||
DEFAULT_HEADER_TYPES.put(IntegrationMessageHeaderAccessor.PRIORITY, Integer.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2022 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.
|
||||
@@ -30,6 +30,7 @@ import org.springframework.messaging.MessageHeaders;
|
||||
* The {@link MessageJacksonDeserializer} implementation for the {@link AdviceMessage}.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.3.10
|
||||
*/
|
||||
@@ -46,7 +47,7 @@ public class AdviceMessageJacksonDeserializer extends MessageJacksonDeserializer
|
||||
protected AdviceMessage<?> buildMessage(MutableMessageHeaders headers, Object payload, JsonNode root,
|
||||
DeserializationContext ctxt) throws IOException {
|
||||
Message<?> inputMessage = getMapper().readValue(root.get("inputMessage").traverse(), Message.class);
|
||||
return new AdviceMessage<Object>(payload, (MessageHeaders) headers, inputMessage);
|
||||
return new AdviceMessage<>(payload, (MessageHeaders) headers, inputMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@@ -197,8 +198,8 @@ public class TransactionSynchronizationFactoryBean implements FactoryBean<Defaul
|
||||
.acceptIfNotNull(this.afterCommitChannel, processor::setAfterCommitChannel)
|
||||
.acceptIfNotNull(this.afterRollbackChannel, processor::setAfterRollbackChannel);
|
||||
|
||||
if (this.beanFactory instanceof AutowireCapableBeanFactory) {
|
||||
((AutowireCapableBeanFactory) this.beanFactory).initializeBean(processor,
|
||||
if (this.beanFactory instanceof AutowireCapableBeanFactory autowireCapableBeanFactory) {
|
||||
autowireCapableBeanFactory.initializeBean(processor,
|
||||
getClass().getName() + "#" + TransactionSynchronizationFactoryBean.this.counter.incrementAndGet());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -37,6 +37,7 @@ import org.springframework.util.ObjectUtils;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractMessageProcessingTransformer
|
||||
implements Transformer, BeanFactoryAware, ManageableLifecycle {
|
||||
@@ -61,8 +62,8 @@ public abstract class AbstractMessageProcessingTransformer
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
if (this.messageProcessor instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.messageProcessor).setBeanFactory(beanFactory);
|
||||
if (this.messageProcessor instanceof BeanFactoryAware beanFactoryAware) {
|
||||
beanFactoryAware.setBeanFactory(beanFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,21 +79,21 @@ public abstract class AbstractMessageProcessingTransformer
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (this.messageProcessor instanceof Lifecycle) {
|
||||
((Lifecycle) this.messageProcessor).start();
|
||||
if (this.messageProcessor instanceof Lifecycle lifecycle) {
|
||||
lifecycle.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if (this.messageProcessor instanceof Lifecycle) {
|
||||
((Lifecycle) this.messageProcessor).stop();
|
||||
if (this.messageProcessor instanceof Lifecycle lifecycle) {
|
||||
lifecycle.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return !(this.messageProcessor instanceof Lifecycle) || ((Lifecycle) this.messageProcessor).isRunning();
|
||||
return !(this.messageProcessor instanceof Lifecycle lifecycle) || lifecycle.isRunning();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Gary Russell
|
||||
* @author Soby Chacko
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware {
|
||||
|
||||
@@ -61,10 +62,10 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
if (beanFactory instanceof ConfigurableBeanFactory) {
|
||||
Object typeConverter = ((ConfigurableBeanFactory) beanFactory).getTypeConverter();
|
||||
if (typeConverter instanceof SimpleTypeConverter) {
|
||||
this.delegate = (SimpleTypeConverter) typeConverter;
|
||||
if (beanFactory instanceof ConfigurableBeanFactory configurableBeanFactory) {
|
||||
Object typeConverter = configurableBeanFactory.getTypeConverter();
|
||||
if (typeConverter instanceof SimpleTypeConverter simpleTypeConverter) {
|
||||
this.delegate = simpleTypeConverter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -50,6 +50,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Soby Chacko
|
||||
* @author Artem Bilan
|
||||
* @author Chris Bono
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@@ -177,7 +178,7 @@ public final class MessagingAnnotationUtils {
|
||||
Set<Annotation> visited = new HashSet<>();
|
||||
|
||||
recursiveFindAnnotation(annotationType, messagingAnnotation, annotationChain, visited);
|
||||
if (annotationChain.size() > 0) {
|
||||
if (!annotationChain.isEmpty()) {
|
||||
Collections.reverse(annotationChain);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Gary Russell
|
||||
* @author Christian Tzolov
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class UUIDConverter implements Converter<Object, UUID> {
|
||||
|
||||
@@ -66,8 +67,8 @@ public class UUIDConverter implements Converter<Object, UUID> {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (input instanceof UUID) {
|
||||
return (UUID) input;
|
||||
if (input instanceof UUID uuid) {
|
||||
return uuid;
|
||||
}
|
||||
if (input instanceof String inputText) {
|
||||
if (isValidUuidStringRepresentation(inputText)) {
|
||||
|
||||
@@ -26,11 +26,12 @@ import org.springframework.util.ReflectionUtils.MethodFilter;
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
* @since 2.0
|
||||
*/
|
||||
public class UniqueMethodFilter implements MethodFilter {
|
||||
|
||||
private final List<Method> uniqueMethods = new ArrayList<Method>();
|
||||
private final List<Method> uniqueMethods = new ArrayList<>();
|
||||
|
||||
public UniqueMethodFilter(Class<?> targetClass) {
|
||||
Method[] allMethods = ReflectionUtils.getAllDeclaredMethods(targetClass);
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @see ApplicationEventMulticaster
|
||||
* @see ExpressionMessageProducerSupport
|
||||
@@ -80,7 +81,7 @@ public class ApplicationEventListeningMessageProducer extends ExpressionMessageP
|
||||
eventSet.add(ResolvableType.forClass(eventType));
|
||||
}
|
||||
}
|
||||
this.eventTypes = (eventSet.size() > 0 ? eventSet : null);
|
||||
this.eventTypes = (!eventSet.isEmpty() ? eventSet : null);
|
||||
|
||||
if (this.applicationEventMulticaster != null) {
|
||||
this.applicationEventMulticaster.addApplicationListener(this);
|
||||
|
||||
@@ -112,6 +112,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Alen Turkovic
|
||||
* @author Trung Pham
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class FileWritingMessageHandler extends AbstractReplyProducingMessageHandler
|
||||
implements ManageableLifecycle, MessageTriggerAction {
|
||||
@@ -475,9 +476,9 @@ public class FileWritingMessageHandler extends AbstractReplyProducingMessageHand
|
||||
}
|
||||
Flusher flusher = new Flusher();
|
||||
flusher.run();
|
||||
boolean needInterrupt = this.fileStates.size() > 0;
|
||||
boolean needInterrupt = !this.fileStates.isEmpty();
|
||||
int n = 0;
|
||||
while (n++ < 10 && this.fileStates.size() > 0) { // NOSONAR
|
||||
while (n++ < 10 && !this.fileStates.isEmpty()) { // NOSONAR
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
}
|
||||
@@ -486,7 +487,7 @@ public class FileWritingMessageHandler extends AbstractReplyProducingMessageHand
|
||||
}
|
||||
flusher.run();
|
||||
}
|
||||
if (this.fileStates.size() > 0) {
|
||||
if (!this.fileStates.isEmpty()) {
|
||||
this.logger.error("Failed to flush after multiple attempts, while stopping: " + this.fileStates.keySet());
|
||||
}
|
||||
if (needInterrupt) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -29,12 +29,13 @@ import java.util.List;
|
||||
* @author Mark Fisher
|
||||
* @author Iwein Fuld
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractFileListFilter<F> implements FileListFilter<F> {
|
||||
|
||||
@Override
|
||||
public final List<F> filterFiles(F[] files) {
|
||||
List<F> accepted = new ArrayList<F>();
|
||||
List<F> accepted = new ArrayList<>();
|
||||
if (files != null) {
|
||||
for (F file : files) {
|
||||
if (this.accept(file)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2021 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.
|
||||
@@ -37,6 +37,7 @@ import java.util.stream.Collectors;
|
||||
* @param <F> the target protocol file type.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 5.0
|
||||
*
|
||||
@@ -125,7 +126,7 @@ public abstract class AbstractMarkerFilePresentFileListFilter<F> implements File
|
||||
boolean anyMatch = this.filtersAndFunctions.entrySet().stream().anyMatch(entry -> {
|
||||
F[] fileToCheck = (F[]) Array.newInstance(file.getClass(), 1);
|
||||
fileToCheck[0] = file;
|
||||
if (entry.getKey().filterFiles(fileToCheck).size() > 0) {
|
||||
if (!entry.getKey().filterFiles(fileToCheck).isEmpty()) {
|
||||
String markerName = entry.getValue().apply(getFilename(file));
|
||||
return markerName != null && candidates.contains(markerName);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2021 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -35,6 +35,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
@@ -56,8 +57,8 @@ public abstract class AbstractPersistentAcceptOnceFileListFilter<F> extends Abst
|
||||
Assert.notNull(prefix, "'prefix' cannot be null");
|
||||
this.store = store;
|
||||
this.prefix = prefix;
|
||||
if (store instanceof Flushable) {
|
||||
this.flushableStore = (Flushable) store;
|
||||
if (store instanceof Flushable flushable) {
|
||||
this.flushableStore = flushable;
|
||||
}
|
||||
else {
|
||||
this.flushableStore = null;
|
||||
@@ -130,8 +131,8 @@ public abstract class AbstractPersistentAcceptOnceFileListFilter<F> extends Abst
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (this.store instanceof Closeable) {
|
||||
((Closeable) this.store).close();
|
||||
if (this.store instanceof Closeable closeable) {
|
||||
closeable.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.springframework.lang.Nullable;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class AcceptOnceFileListFilter<F> extends AbstractFileListFilter<F> implements ReversibleFileListFilter<F>,
|
||||
ResettableFileListFilter<F> {
|
||||
@@ -47,7 +48,7 @@ public class AcceptOnceFileListFilter<F> extends AbstractFileListFilter<F> imple
|
||||
@Nullable
|
||||
private final Queue<F> seen;
|
||||
|
||||
private final Set<F> seenSet = new HashSet<F>();
|
||||
private final Set<F> seenSet = new HashSet<>();
|
||||
|
||||
private final Lock monitor = new ReentrantLock();
|
||||
|
||||
@@ -58,7 +59,7 @@ public class AcceptOnceFileListFilter<F> extends AbstractFileListFilter<F> imple
|
||||
* @param maxCapacity the maximum number of Files to maintain in the 'seen' queue.
|
||||
*/
|
||||
public AcceptOnceFileListFilter(int maxCapacity) {
|
||||
this.seen = new LinkedBlockingQueue<F>(maxCapacity);
|
||||
this.seen = new LinkedBlockingQueue<>(maxCapacity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,6 +74,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -137,7 +138,7 @@ public abstract class AbstractInboundFileSynchronizer<F>
|
||||
*/
|
||||
public AbstractInboundFileSynchronizer(SessionFactory<F> sessionFactory) {
|
||||
Assert.notNull(sessionFactory, "sessionFactory must not be null");
|
||||
this.remoteFileTemplate = new RemoteFileTemplate<F>(sessionFactory);
|
||||
this.remoteFileTemplate = new RemoteFileTemplate<>(sessionFactory);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -312,8 +313,8 @@ public abstract class AbstractInboundFileSynchronizer<F>
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (this.filter instanceof Closeable) {
|
||||
((Closeable) this.filter).close();
|
||||
if (this.filter instanceof Closeable closeable) {
|
||||
closeable.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2022 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.
|
||||
@@ -50,6 +50,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Eren Avsarogullari
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 6.0
|
||||
*/
|
||||
@@ -218,9 +219,9 @@ public abstract class AbstractHazelcastMessageProducer extends MessageProducerSu
|
||||
entryEvent.getValue(), entryEvent.getOldValue());
|
||||
return getMessageBuilderFactory().withPayload(messagePayload).copyHeaders(headers).build();
|
||||
}
|
||||
else if (event instanceof MapEvent) {
|
||||
else if (event instanceof MapEvent mapEvent) {
|
||||
return getMessageBuilderFactory()
|
||||
.withPayload(((MapEvent) event).getNumberOfEntriesAffected()).copyHeaders(headers).build();
|
||||
.withPayload(mapEvent.getNumberOfEntriesAffected()).copyHeaders(headers).build();
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("Invalid event is received. Event : " + event);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2023 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.
|
||||
@@ -52,6 +52,7 @@ import org.springframework.validation.Validator;
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Trung Pham
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
@@ -311,14 +312,14 @@ public class BaseHttpInboundEndpoint extends MessagingGatewaySupport implements
|
||||
|
||||
private HttpStatus buildHttpStatus(Object httpStatusValue) {
|
||||
HttpStatus httpStatus = null;
|
||||
if (httpStatusValue instanceof HttpStatus) {
|
||||
httpStatus = (HttpStatus) httpStatusValue;
|
||||
if (httpStatusValue instanceof HttpStatus castHttpStatus) {
|
||||
httpStatus = castHttpStatus;
|
||||
}
|
||||
else if (httpStatusValue instanceof Integer) {
|
||||
httpStatus = HttpStatus.valueOf((Integer) httpStatusValue);
|
||||
else if (httpStatusValue instanceof Integer integer) {
|
||||
httpStatus = HttpStatus.valueOf(integer);
|
||||
}
|
||||
else if (httpStatusValue instanceof String) {
|
||||
httpStatus = HttpStatus.valueOf(Integer.parseInt((String) httpStatusValue));
|
||||
else if (httpStatusValue instanceof String string) {
|
||||
httpStatus = HttpStatus.valueOf(Integer.parseInt(string));
|
||||
}
|
||||
return httpStatus;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ import org.springframework.web.util.DefaultUriBuilderFactory;
|
||||
* @author Shiliang Li
|
||||
* @author Florian Schöffl
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
@@ -404,7 +405,7 @@ public abstract class AbstractHttpRequestExecutingMessageHandler extends Abstrac
|
||||
private HttpEntity<?> createHttpEntityFromMessage(Message<?> message, HttpMethod httpMethod) {
|
||||
HttpHeaders httpHeaders = mapHeaders(message);
|
||||
if (shouldIncludeRequestBody(httpMethod)) {
|
||||
return new HttpEntity<Object>(message, httpHeaders);
|
||||
return new HttpEntity<>(message, httpHeaders);
|
||||
}
|
||||
return new HttpEntity<>(httpHeaders);
|
||||
}
|
||||
@@ -447,11 +448,11 @@ public abstract class AbstractHttpRequestExecutingMessageHandler extends Abstrac
|
||||
for (Entry<?, ?> entry : simpleMap.entrySet()) {
|
||||
Object key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof Object[]) {
|
||||
value = Arrays.asList((Object[]) value);
|
||||
if (value instanceof Object[] objects) {
|
||||
value = Arrays.asList(objects);
|
||||
}
|
||||
if (value instanceof Collection) {
|
||||
multipartValueMap.put(key, new ArrayList<>((Collection<?>) value));
|
||||
if (value instanceof Collection<?> collection) {
|
||||
multipartValueMap.put(key, new ArrayList<>(collection));
|
||||
}
|
||||
else {
|
||||
multipartValueMap.add(key, value);
|
||||
@@ -502,8 +503,8 @@ public abstract class AbstractHttpRequestExecutingMessageHandler extends Abstrac
|
||||
Assert.state((httpMethod instanceof String || httpMethod instanceof HttpMethod), () ->
|
||||
"'httpMethodExpression' evaluation must result in an 'HttpMethod' enum or its String representation, " +
|
||||
"not: " + (httpMethod == null ? "null" : httpMethod.getClass()));
|
||||
if (httpMethod instanceof HttpMethod) {
|
||||
return (HttpMethod) httpMethod;
|
||||
if (httpMethod instanceof HttpMethod castHttpMethod) {
|
||||
return castHttpMethod;
|
||||
}
|
||||
else {
|
||||
try {
|
||||
@@ -537,9 +538,9 @@ public abstract class AbstractHttpRequestExecutingMessageHandler extends Abstrac
|
||||
() -> "The '" + property + "' can be an instance of 'Class<?>', 'String' " +
|
||||
"or 'ParameterizedTypeReference<?>'; " +
|
||||
"evaluation resulted in a " + typeClass + ".");
|
||||
if (type instanceof String && StringUtils.hasText((String) type)) {
|
||||
if (type instanceof String string && StringUtils.hasText(string)) {
|
||||
try {
|
||||
type = ClassUtils.forName((String) type, getApplicationContext().getClassLoader());
|
||||
type = ClassUtils.forName(string, getApplicationContext().getClassLoader());
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new IllegalStateException("Cannot load class for name: " + type, e);
|
||||
|
||||
@@ -61,6 +61,7 @@ import org.springframework.util.Assert;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
@@ -153,9 +154,8 @@ public abstract class AbstractConnectionFactory extends IntegrationObjectSupport
|
||||
@Override
|
||||
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
|
||||
this.applicationEventPublisher = applicationEventPublisher;
|
||||
if (!this.deserializerSet && this.deserializer instanceof ApplicationEventPublisherAware) {
|
||||
((ApplicationEventPublisherAware) this.deserializer)
|
||||
.setApplicationEventPublisher(applicationEventPublisher);
|
||||
if (!this.deserializerSet && this.deserializer instanceof ApplicationEventPublisherAware applicationEventPublisherAware) {
|
||||
applicationEventPublisherAware.setApplicationEventPublisher(applicationEventPublisher);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ public abstract class AbstractConnectionFactory extends IntegrationObjectSupport
|
||||
*/
|
||||
@Nullable
|
||||
public TcpSender getSender() {
|
||||
return this.senders.size() > 0 ? this.senders.get(0) : null;
|
||||
return !this.senders.isEmpty() ? this.senders.get(0) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -827,7 +827,7 @@ public abstract class AbstractConnectionFactory extends IntegrationObjectSupport
|
||||
private void rescheduleDelayedReads(Selector selector, long now) {
|
||||
boolean wakeSelector = false;
|
||||
try {
|
||||
while (this.delayedReads.size() > 0) {
|
||||
while (!this.delayedReads.isEmpty()) {
|
||||
if (this.delayedReads.peek().failedAt + this.readDelay < now) {
|
||||
PendingIO pendingRead = this.delayedReads.take();
|
||||
if (pendingRead.key.channel().isOpen()) {
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.messaging.support.ErrorMessage;
|
||||
* @author Gary Russell
|
||||
* @author Kazuki Shimizu
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -110,7 +111,7 @@ public abstract class TcpConnectionInterceptorSupport extends TcpConnectionSuppo
|
||||
@Override
|
||||
public void registerSenders(List<TcpSender> sendersToRegister) {
|
||||
this.interceptedSenders = sendersToRegister;
|
||||
if (sendersToRegister.size() > 0) {
|
||||
if (!sendersToRegister.isEmpty()) {
|
||||
if (!(sendersToRegister.get(0) instanceof TcpConnectionInterceptorSupport)) {
|
||||
this.realSender = true;
|
||||
}
|
||||
@@ -249,8 +250,8 @@ public abstract class TcpConnectionInterceptorSupport extends TcpConnectionSuppo
|
||||
return;
|
||||
}
|
||||
this.removed = true;
|
||||
if (this.theConnection instanceof TcpConnectionInterceptorSupport && !this.theConnection.equals(this)) {
|
||||
((TcpConnectionInterceptorSupport) this.theConnection).removeDeadConnection(this);
|
||||
if (this.theConnection instanceof TcpConnectionInterceptorSupport tcpConnectionInterceptorSupport && !this.theConnection.equals(this)) {
|
||||
tcpConnectionInterceptorSupport.removeDeadConnection(this);
|
||||
}
|
||||
TcpSender sender = getSender();
|
||||
if (sender != null && !(sender instanceof TcpConnectionInterceptorSupport)) {
|
||||
@@ -270,7 +271,7 @@ public abstract class TcpConnectionInterceptorSupport extends TcpConnectionSuppo
|
||||
@Override
|
||||
@Nullable
|
||||
public TcpSender getSender() {
|
||||
return this.interceptedSenders != null && this.interceptedSenders.size() > 0
|
||||
return this.interceptedSenders != null && !this.interceptedSenders.isEmpty()
|
||||
? this.interceptedSenders.get(0)
|
||||
: null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2022 the original author or authors.
|
||||
* Copyright 2001-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.
|
||||
@@ -48,6 +48,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
@@ -370,7 +371,7 @@ public abstract class TcpConnectionSupport implements TcpConnection {
|
||||
*/
|
||||
@Nullable
|
||||
public TcpSender getSender() {
|
||||
return this.senders.size() > 0 ? this.senders.get(0) : null;
|
||||
return !this.senders.isEmpty() ? this.senders.get(0) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-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 @@ import org.springframework.util.MimeType;
|
||||
* *
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
@@ -260,12 +261,12 @@ public class TcpMessageMapper implements
|
||||
private byte[] getPayloadAsBytes(Message<?> message) {
|
||||
byte[] bytes = null;
|
||||
Object payload = message.getPayload();
|
||||
if (payload instanceof byte[]) {
|
||||
bytes = (byte[]) payload;
|
||||
if (payload instanceof byte[] castBytes) {
|
||||
bytes = castBytes;
|
||||
}
|
||||
else if (payload instanceof String) {
|
||||
else if (payload instanceof String string) {
|
||||
try {
|
||||
bytes = ((String) payload).getBytes(this.charset);
|
||||
bytes = string.getBytes(this.charset);
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2023 the original author or authors.
|
||||
* Copyright 2001-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.
|
||||
@@ -46,6 +46,7 @@ import org.springframework.util.Assert;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
@@ -172,8 +173,8 @@ public class TcpNetConnection extends TcpConnectionSupport implements Scheduling
|
||||
@Override
|
||||
@Nullable
|
||||
public SSLSession getSslSession() {
|
||||
if (this.socket instanceof SSLSocket) {
|
||||
return ((SSLSocket) this.socket).getSession();
|
||||
if (this.socket instanceof SSLSocket sslSocket) {
|
||||
return sslSocket.getSession();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.springframework.util.Assert;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
@@ -210,7 +211,7 @@ public class TcpNioClientConnectionFactory extends
|
||||
int selectionCount = 0;
|
||||
try {
|
||||
long timeout = Math.max(soTimeout, 0);
|
||||
if (getDelayedReads().size() > 0 && (timeout == 0 || getReadDelay() < timeout)) {
|
||||
if (!getDelayedReads().isEmpty() && (timeout == 0 || getReadDelay() < timeout)) {
|
||||
timeout = getReadDelay();
|
||||
}
|
||||
selectionCount = this.selector.select(timeout);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -41,6 +41,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
@@ -185,7 +186,7 @@ public class TcpNioServerConnectionFactory extends AbstractServerConnectionFacto
|
||||
int selectionCount;
|
||||
try {
|
||||
long timeout = Math.max(soTimeout, 0);
|
||||
if (getDelayedReads().size() > 0 && (timeout == 0 || getReadDelay() < timeout)) {
|
||||
if (!getDelayedReads().isEmpty() && (timeout == 0 || getReadDelay() < timeout)) {
|
||||
timeout = getReadDelay();
|
||||
}
|
||||
long timeoutToLog = timeout;
|
||||
|
||||
@@ -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.
|
||||
@@ -28,6 +28,7 @@ import org.springframework.util.Assert;
|
||||
* Optionally pools buffers.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
* @since 4.3
|
||||
*
|
||||
*/
|
||||
@@ -44,7 +45,7 @@ public abstract class AbstractPooledBufferByteArraySerializer extends AbstractBy
|
||||
*/
|
||||
public void setPoolSize(int size) {
|
||||
Assert.isNull(this.pool, "Cannot change pool size once set");
|
||||
this.pool = new SimplePool<byte[]>(size, new PoolItemCallback<byte[]>() {
|
||||
this.pool = new SimplePool<>(size, new PoolItemCallback<>() {
|
||||
|
||||
@Override
|
||||
public byte[] createForPool() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2023 the original author or authors.
|
||||
* Copyright 2001-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.
|
||||
@@ -61,6 +61,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Marcin Pilaczynski
|
||||
* @author Artem Bilan
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -357,15 +358,14 @@ public class UnicastSendingMessageHandler extends
|
||||
SocketAddress destinationAddress;
|
||||
if (this.destinationExpression != null) {
|
||||
Object destination = this.destinationExpression.getValue(this.evaluationContext, message);
|
||||
if (destination instanceof String) {
|
||||
destination = new URI((String) destination);
|
||||
if (destination instanceof String string) {
|
||||
destination = new URI(string);
|
||||
}
|
||||
if (destination instanceof URI) {
|
||||
URI uri = (URI) destination;
|
||||
if (destination instanceof URI uri) {
|
||||
destination = new InetSocketAddress(uri.getHost(), uri.getPort());
|
||||
}
|
||||
if (destination instanceof SocketAddress) {
|
||||
destinationAddress = (SocketAddress) destination;
|
||||
if (destination instanceof SocketAddress socketAddress) {
|
||||
destinationAddress = socketAddress;
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("'destinationExpression' must evaluate to String, URI " +
|
||||
|
||||
@@ -86,6 +86,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Meherzad Lahewala
|
||||
* @author Trung Pham
|
||||
* @author Johannes Edmeier
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.2
|
||||
*/
|
||||
@@ -609,7 +610,7 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto
|
||||
|
||||
Assert.state(messages.size() < 2,
|
||||
() -> "The query must return zero or 1 row; got " + messages.size() + " rows");
|
||||
if (messages.size() > 0) {
|
||||
if (!messages.isEmpty()) {
|
||||
|
||||
final Message<?> message = messages.get(0);
|
||||
UUID id = message.getHeaders().getId();
|
||||
|
||||
@@ -79,6 +79,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Will Schipp
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -752,7 +753,7 @@ public class JdbcMessageStore extends AbstractMessageGroupStore
|
||||
groupIdKey, this.region, groupIdKey, this.region);
|
||||
Assert.state(messages.size() < 2,
|
||||
() -> "The query must return zero or 1 row; got " + messages.size() + " rows");
|
||||
if (messages.size() > 0) {
|
||||
if (!messages.isEmpty()) {
|
||||
return messages.get(0);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -77,6 +77,7 @@ import org.springframework.util.Assert;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class ChannelPublishingJmsMessageListener
|
||||
implements SessionAwareMessageListener<jakarta.jms.Message>, InitializingBean,
|
||||
@@ -558,8 +559,8 @@ public class ChannelPublishingJmsMessageListener
|
||||
* @see #setDestinationResolver
|
||||
*/
|
||||
private Destination resolveDefaultReplyDestination(Session session) throws JMSException {
|
||||
if (this.defaultReplyDestination instanceof Destination) {
|
||||
return (Destination) this.defaultReplyDestination;
|
||||
if (this.defaultReplyDestination instanceof Destination destination) {
|
||||
return destination;
|
||||
}
|
||||
if (this.defaultReplyDestination instanceof DestinationNameHolder nameHolder) {
|
||||
return this.destinationResolver.resolveDestinationName(session, nameHolder.name, nameHolder.isTopic);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -35,6 +35,7 @@ import org.springframework.messaging.support.ExecutorChannelInterceptor;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -77,7 +78,7 @@ public class PollableJmsChannel extends AbstractJmsChannel
|
||||
if (isLoggingEnabled()) {
|
||||
logger.trace(() -> "preReceive on channel '" + this + "'");
|
||||
}
|
||||
if (interceptorList.getInterceptors().size() > 0) {
|
||||
if (!interceptorList.getInterceptors().isEmpty()) {
|
||||
interceptorStack = new ArrayDeque<>();
|
||||
|
||||
if (!interceptorList.preReceive(this, interceptorStack)) {
|
||||
|
||||
@@ -48,6 +48,7 @@ import org.springframework.util.Assert;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Trung Pham
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -118,7 +119,7 @@ public class NotificationPublishingMessageHandler extends AbstractMessageHandler
|
||||
Map<String, MBeanExporter> exporters =
|
||||
BeanFactoryUtils.beansOfTypeIncludingAncestors((ListableBeanFactory) beanFactory,
|
||||
MBeanExporter.class);
|
||||
Assert.state(exporters.size() > 0, "No MBeanExporter is available in the current context.");
|
||||
Assert.state(!exporters.isEmpty(), "No MBeanExporter is available in the current context.");
|
||||
MBeanExporter exporter = null;
|
||||
for (MBeanExporter exp : exporters.values()) {
|
||||
exporter = exp;
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.beans.PropertyAccessorFactory;
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.2
|
||||
*
|
||||
@@ -69,7 +70,7 @@ public class BeanPropertyParameterSource implements ParameterSource {
|
||||
*/
|
||||
public String[] getReadablePropertyNames() {
|
||||
if (this.propertyNames == null) {
|
||||
final List<String> names = new ArrayList<String>();
|
||||
final List<String> names = new ArrayList<>();
|
||||
PropertyDescriptor[] props = this.beanWrapper.getPropertyDescriptors();
|
||||
for (PropertyDescriptor pd : props) {
|
||||
if (this.beanWrapper.isReadableProperty(pd.getName())) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020 the original author or authors.
|
||||
* Copyright 2020-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.
|
||||
@@ -37,6 +37,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 5.4
|
||||
*
|
||||
@@ -85,7 +86,7 @@ public class PollableKafkaChannel extends AbstractKafkaChannel
|
||||
if (isLoggingEnabled()) {
|
||||
logger.trace(() -> "preReceive on channel '" + this + "'");
|
||||
}
|
||||
if (interceptorList.getInterceptors().size() > 0) {
|
||||
if (!interceptorList.getInterceptors().isEmpty()) {
|
||||
interceptorStack = new ArrayDeque<>();
|
||||
if (!interceptorList.preReceive(this, interceptorStack)) {
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2023 the original author or authors.
|
||||
* Copyright 2018-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.
|
||||
@@ -104,6 +104,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Artem Bilan
|
||||
* @author Anshul Mehra
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 5.4
|
||||
*
|
||||
@@ -843,7 +844,7 @@ public class KafkaMessageSource<K, V> extends AbstractMessageSource<Object>
|
||||
return i.getRecord().offset();
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
if (rewound.size() > 0) {
|
||||
if (!rewound.isEmpty()) {
|
||||
this.logger.warn(() -> "Rolled back " + KafkaUtils.format(record)
|
||||
+ " later in-flight offsets "
|
||||
+ rewound + " will also be re-fetched");
|
||||
@@ -875,7 +876,7 @@ public class KafkaMessageSource<K, V> extends AbstractMessageSource<Object>
|
||||
}
|
||||
}
|
||||
}
|
||||
if (toCommit.size() > 0) {
|
||||
if (!toCommit.isEmpty()) {
|
||||
ackInformation = toCommit.get(toCommit.size() - 1);
|
||||
KafkaAckInfo<K, V> ackInformationToLog = ackInformation;
|
||||
this.commitLogger.log(() -> "Committing pending offsets for "
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -67,6 +67,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Artem Bilan
|
||||
* @author Dominik Simmen
|
||||
* @author Yuxin Wang
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractMailReceiver extends IntegrationObjectSupport implements MailReceiver, DisposableBean {
|
||||
|
||||
@@ -474,19 +475,19 @@ public abstract class AbstractMailReceiver extends IntegrationObjectSupport impl
|
||||
headers.put(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN_VALUE);
|
||||
}
|
||||
}
|
||||
else if (content instanceof InputStream) {
|
||||
else if (content instanceof InputStream inputStream) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
FileCopyUtils.copy((InputStream) content, baos);
|
||||
FileCopyUtils.copy(inputStream, baos);
|
||||
content = byteArrayToContent(headers, baos);
|
||||
}
|
||||
else if (content instanceof Multipart && this.embeddedPartsAsBytes) {
|
||||
else if (content instanceof Multipart multipart && this.embeddedPartsAsBytes) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
((Multipart) content).writeTo(baos);
|
||||
multipart.writeTo(baos);
|
||||
content = byteArrayToContent(headers, baos);
|
||||
}
|
||||
else if (content instanceof Part && this.embeddedPartsAsBytes) {
|
||||
else if (content instanceof Part part && this.embeddedPartsAsBytes) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
((Part) content).writeTo(baos);
|
||||
part.writeTo(baos);
|
||||
content = byteArrayToContent(headers, baos);
|
||||
}
|
||||
return content;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021-2022 the original author or authors.
|
||||
* Copyright 2021-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.
|
||||
@@ -51,6 +51,7 @@ import org.springframework.util.MultiValueMap;
|
||||
* @param <T> The payload type.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 5.5
|
||||
*/
|
||||
@@ -175,9 +176,9 @@ public abstract class AbstractMongoDbMessageSource<T> extends AbstractMessageSou
|
||||
protected void onInit() {
|
||||
super.onInit();
|
||||
TypeLocator typeLocator = getEvaluationContext().getTypeLocator();
|
||||
if (typeLocator instanceof StandardTypeLocator) {
|
||||
if (typeLocator instanceof StandardTypeLocator standardTypeLocator) {
|
||||
//Register MongoDB query API package so FQCN can be avoided in query-expression.
|
||||
((StandardTypeLocator) typeLocator).registerImport("org.springframework.data.mongodb.core.query");
|
||||
standardTypeLocator.registerImport("org.springframework.data.mongodb.core.query");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,11 +186,11 @@ public abstract class AbstractMongoDbMessageSource<T> extends AbstractMessageSou
|
||||
Object value = this.queryExpression.getValue(getEvaluationContext());
|
||||
Assert.notNull(value, "'queryExpression' must not evaluate to null");
|
||||
Query query = null;
|
||||
if (value instanceof String) {
|
||||
query = new BasicQuery((String) value);
|
||||
if (value instanceof String string) {
|
||||
query = new BasicQuery(string);
|
||||
}
|
||||
else if (value instanceof Query) {
|
||||
query = ((Query) value);
|
||||
else if (value instanceof Query castQuery) {
|
||||
query = castQuery;
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("'queryExpression' must evaluate to String " +
|
||||
@@ -244,11 +245,11 @@ public abstract class AbstractMongoDbMessageSource<T> extends AbstractMessageSou
|
||||
Object value = this.updateExpression.getValue(getEvaluationContext());
|
||||
Assert.notNull(value, "'updateExpression' must not evaluate to null");
|
||||
Update update;
|
||||
if (value instanceof String) {
|
||||
update = new BasicUpdate((String) value);
|
||||
if (value instanceof String string) {
|
||||
update = new BasicUpdate(string);
|
||||
}
|
||||
else if (value instanceof Update) {
|
||||
update = ((Update) value);
|
||||
else if (value instanceof Update castUpdate) {
|
||||
update = castUpdate;
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("'updateExpression' must evaluate to String " +
|
||||
|
||||
@@ -53,6 +53,7 @@ import org.springframework.util.Assert;
|
||||
* @author Amol Nayak
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
@@ -194,7 +195,7 @@ public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDb
|
||||
ids.clear();
|
||||
}
|
||||
}
|
||||
if (ids.size() > 0) {
|
||||
if (!ids.isEmpty()) {
|
||||
removeMessages(groupId, ids);
|
||||
}
|
||||
updateGroup(groupId, lastModifiedUpdate());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -37,6 +37,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
/**
|
||||
* @author David Turanski
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractScriptParser extends AbstractSingleBeanDefinitionParser {
|
||||
@@ -63,7 +64,7 @@ public abstract class AbstractScriptParser extends AbstractSingleBeanDefinitionP
|
||||
List<Element> variableElements = DomUtils.getChildElementsByTagName(element, "variable");
|
||||
String scriptVariableGeneratorName = element.getAttribute("script-variable-generator");
|
||||
|
||||
if (StringUtils.hasText(scriptVariableGeneratorName) && variableElements.size() > 0) {
|
||||
if (StringUtils.hasText(scriptVariableGeneratorName) && !variableElements.isEmpty()) {
|
||||
parserContext.getReaderContext().error(
|
||||
"'script-variable-generator' and 'variable' sub-elements are mutually exclusive.", element);
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -40,6 +40,7 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -79,7 +80,7 @@ public abstract class AbstractScriptExecutor implements ScriptExecutor {
|
||||
}
|
||||
|
||||
Bindings bindings = null;
|
||||
if (variables != null && variables.size() > 0) {
|
||||
if (variables != null && !variables.isEmpty()) {
|
||||
bindings = new SimpleBindings(variables);
|
||||
result = this.scriptEngine.eval(script, bindings);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.messaging.MessagingException;
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class ByteStreamReadingMessageSource extends AbstractMessageSource<byte[]> {
|
||||
|
||||
@@ -47,8 +48,8 @@ public class ByteStreamReadingMessageSource extends AbstractMessageSource<byte[]
|
||||
}
|
||||
|
||||
public ByteStreamReadingMessageSource(InputStream stream, int bufferSize) {
|
||||
if (stream instanceof BufferedInputStream) {
|
||||
this.stream = (BufferedInputStream) stream;
|
||||
if (stream instanceof BufferedInputStream bufferedInputStream) {
|
||||
this.stream = bufferedInputStream;
|
||||
}
|
||||
else if (bufferSize > 0) {
|
||||
this.stream = new BufferedInputStream(stream, bufferSize);
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.springframework.messaging.MessagingException;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class ByteStreamWritingMessageHandler extends AbstractMessageHandler {
|
||||
|
||||
@@ -57,11 +58,11 @@ public class ByteStreamWritingMessageHandler extends AbstractMessageHandler {
|
||||
protected void handleMessageInternal(Message<?> message) {
|
||||
Object payload = message.getPayload();
|
||||
try {
|
||||
if (payload instanceof String) {
|
||||
this.stream.write(((String) payload).getBytes());
|
||||
if (payload instanceof String string) {
|
||||
this.stream.write(string.getBytes());
|
||||
}
|
||||
else if (payload instanceof byte[]) {
|
||||
this.stream.write((byte[]) payload);
|
||||
else if (payload instanceof byte[] bytes) {
|
||||
this.stream.write(bytes);
|
||||
}
|
||||
else {
|
||||
throw new MessagingException(this.getClass().getSimpleName() +
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.util.Assert;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class CharacterStreamReadingMessageSource extends AbstractMessageSource<String>
|
||||
implements ApplicationEventPublisherAware {
|
||||
@@ -92,8 +93,8 @@ public class CharacterStreamReadingMessageSource extends AbstractMessageSource<S
|
||||
*/
|
||||
public CharacterStreamReadingMessageSource(Reader reader, int bufferSize, boolean blockToDetectEOF) {
|
||||
Assert.notNull(reader, "reader must not be null");
|
||||
if (reader instanceof BufferedReader) {
|
||||
this.reader = (BufferedReader) reader;
|
||||
if (reader instanceof BufferedReader bufferedReader) {
|
||||
this.reader = bufferedReader;
|
||||
}
|
||||
else if (bufferSize > 0) {
|
||||
this.reader = new BufferedReader(reader, bufferSize);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-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,7 @@ import org.springframework.messaging.support.ErrorMessage;
|
||||
* Base support class for inbound channel adapters. The default port is 514.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
* @since 3.0
|
||||
*
|
||||
*/
|
||||
@@ -79,9 +80,9 @@ public abstract class SyslogReceivingChannelAdapterSupport extends MessageProduc
|
||||
|
||||
protected void convertAndSend(Message<?> message) {
|
||||
try {
|
||||
if (message instanceof ErrorMessage) {
|
||||
if (message instanceof ErrorMessage errorMessage) {
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Error on syslog socket:" + ((ErrorMessage) message).getPayload().getMessage());
|
||||
this.logger.debug("Error on syslog socket:" + errorMessage.getPayload().getMessage());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2023 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.
|
||||
@@ -37,6 +37,7 @@ import org.springframework.integration.webflux.support.WebFluxContextUtils;
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Chris Bono
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
@@ -46,8 +47,8 @@ public class WebFluxIntegrationConfigurationInitializer implements IntegrationCo
|
||||
|
||||
@Override
|
||||
public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
if (beanFactory instanceof BeanDefinitionRegistry) {
|
||||
registerReactiveRequestMappingHandlerMappingIfNecessary((BeanDefinitionRegistry) beanFactory);
|
||||
if (beanFactory instanceof BeanDefinitionRegistry beanDefinitionRegistry) {
|
||||
registerReactiveRequestMappingHandlerMappingIfNecessary(beanDefinitionRegistry);
|
||||
}
|
||||
else {
|
||||
LOGGER.warn("'IntegrationRequestMappingHandlerMapping' isn't registered because 'beanFactory'" +
|
||||
|
||||
@@ -73,6 +73,7 @@ import org.springframework.web.server.WebHandler;
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 5.0
|
||||
*
|
||||
@@ -362,8 +363,8 @@ public class WebFluxInboundEndpoint extends BaseHttpInboundEndpoint implements W
|
||||
responseContent = replyMessage.getPayload();
|
||||
}
|
||||
|
||||
if (responseContent instanceof HttpStatus) {
|
||||
response.setStatusCode((HttpStatus) responseContent);
|
||||
if (responseContent instanceof HttpStatus httpStatus) {
|
||||
response.setStatusCode(httpStatus);
|
||||
return response.setComplete();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -76,6 +76,7 @@ import org.springframework.web.server.WebHandler;
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 5.0
|
||||
*
|
||||
@@ -118,8 +119,8 @@ public class WebFluxIntegrationRequestMappingHandlerMapping extends RequestMappi
|
||||
|
||||
@Override
|
||||
protected void detectHandlerMethods(Object handler) {
|
||||
if (handler instanceof String) {
|
||||
handler = getApplicationContext().getBean((String) handler); // NOSONAR never null
|
||||
if (handler instanceof String string) {
|
||||
handler = getApplicationContext().getBean(string); // NOSONAR never null
|
||||
}
|
||||
RequestMappingInfo mapping = getMappingForEndpoint((WebFluxInboundEndpoint) handler);
|
||||
if (mapping != null) {
|
||||
|
||||
@@ -61,6 +61,7 @@ import org.springframework.web.util.DefaultUriBuilderFactory;
|
||||
* @author Gary Russell
|
||||
* @author David Graff
|
||||
* @author Jatin Saxena
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 5.0
|
||||
*
|
||||
@@ -249,8 +250,8 @@ public class WebFluxRequestExecutingMessageHandler extends AbstractHttpRequestEx
|
||||
WebClient.RequestBodyUriSpec requestBodyUriSpec = this.webClient.method(httpMethod);
|
||||
WebClient.RequestBodySpec requestSpec;
|
||||
|
||||
if (uri instanceof URI) {
|
||||
requestSpec = requestBodyUriSpec.uri((URI) uri);
|
||||
if (uri instanceof URI castUri) {
|
||||
requestSpec = requestBodyUriSpec.uri(castUri);
|
||||
}
|
||||
else {
|
||||
requestSpec = requestBodyUriSpec.uri((String) uri, uriVariables);
|
||||
@@ -287,14 +288,14 @@ public class WebFluxRequestExecutingMessageHandler extends AbstractHttpRequestEx
|
||||
}
|
||||
|
||||
BodyInserter<?, ? super ClientHttpRequest> inserter;
|
||||
if (requestBody instanceof Resource) {
|
||||
inserter = BodyInserters.fromResource((Resource) requestBody);
|
||||
if (requestBody instanceof Resource resource) {
|
||||
inserter = BodyInserters.fromResource(resource);
|
||||
}
|
||||
else if (requestBody instanceof Publisher<?>) {
|
||||
inserter = buildBodyInserterForPublisher(requestMessage, (Publisher<?>) requestBody);
|
||||
else if (requestBody instanceof Publisher<?> publisher) {
|
||||
inserter = buildBodyInserterForPublisher(requestMessage, publisher);
|
||||
}
|
||||
else if (requestBody instanceof MultiValueMap<?, ?>) {
|
||||
inserter = buildBodyInserterForMultiValueMap((MultiValueMap<?, ?>) requestBody,
|
||||
else if (requestBody instanceof MultiValueMap<?, ?> multiValueMap) {
|
||||
inserter = buildBodyInserterForMultiValueMap(multiValueMap,
|
||||
httpRequest.getHeaders().getContentType());
|
||||
}
|
||||
else {
|
||||
@@ -350,8 +351,8 @@ public class WebFluxRequestExecutingMessageHandler extends AbstractHttpRequestEx
|
||||
private BodyExtractor<Flux<Object>, ? super ClientHttpResponse> createBodyExtractor(Object expectedResponseType) {
|
||||
if (expectedResponseType != null) {
|
||||
if (this.replyPayloadToFlux) {
|
||||
if (expectedResponseType instanceof ParameterizedTypeReference) {
|
||||
return BodyExtractors.toFlux((ParameterizedTypeReference) expectedResponseType);
|
||||
if (expectedResponseType instanceof ParameterizedTypeReference parameterizedTypeReference) {
|
||||
return BodyExtractors.toFlux(parameterizedTypeReference);
|
||||
}
|
||||
else {
|
||||
return BodyExtractors.toFlux((Class) expectedResponseType);
|
||||
@@ -359,8 +360,8 @@ public class WebFluxRequestExecutingMessageHandler extends AbstractHttpRequestEx
|
||||
}
|
||||
else {
|
||||
BodyExtractor<? extends Mono<?>, ReactiveHttpInputMessage> monoExtractor;
|
||||
if (expectedResponseType instanceof ParameterizedTypeReference<?>) {
|
||||
monoExtractor = BodyExtractors.toMono((ParameterizedTypeReference) expectedResponseType);
|
||||
if (expectedResponseType instanceof ParameterizedTypeReference<?> parameterizedTypeReference) {
|
||||
monoExtractor = BodyExtractors.toMono(parameterizedTypeReference);
|
||||
}
|
||||
else {
|
||||
monoExtractor = BodyExtractors.toMono((Class) expectedResponseType);
|
||||
@@ -371,8 +372,8 @@ public class WebFluxRequestExecutingMessageHandler extends AbstractHttpRequestEx
|
||||
else if (this.bodyExtractor != null) {
|
||||
return (inputMessage, context) -> {
|
||||
Object body = this.bodyExtractor.extract(inputMessage, context);
|
||||
if (body instanceof Publisher) {
|
||||
return Flux.from((Publisher) body);
|
||||
if (body instanceof Publisher publisher) {
|
||||
return Flux.from(publisher);
|
||||
}
|
||||
return Flux.just(body);
|
||||
};
|
||||
|
||||
@@ -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.
|
||||
@@ -31,6 +31,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
* @since 4.1
|
||||
*/
|
||||
abstract class WebSocketAdapterParsingUtils {
|
||||
@@ -48,7 +49,7 @@ abstract class WebSocketAdapterParsingUtils {
|
||||
boolean hasDefaultProtocolHandler = StringUtils.hasText(defaultProtocolHandler);
|
||||
|
||||
if (hasProtocolHandlers || hasDefaultProtocolHandler) {
|
||||
List<BeanReference> protocolHandlerList = new ManagedList<BeanReference>();
|
||||
List<BeanReference> protocolHandlerList = new ManagedList<>();
|
||||
String[] ids = StringUtils.commaDelimitedListToStringArray(protocolHandlers);
|
||||
for (String id : ids) {
|
||||
protocolHandlerList.add(new RuntimeBeanReference(id));
|
||||
@@ -64,7 +65,7 @@ abstract class WebSocketAdapterParsingUtils {
|
||||
|
||||
String messageConverters = element.getAttribute("message-converters");
|
||||
if (StringUtils.hasText(messageConverters)) {
|
||||
List<BeanReference> messageConverterList = new ManagedList<BeanReference>();
|
||||
List<BeanReference> messageConverterList = new ManagedList<>();
|
||||
String[] ids = StringUtils.commaDelimitedListToStringArray(messageConverters);
|
||||
for (String id : ids) {
|
||||
messageConverterList.add(new RuntimeBeanReference(id));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2023 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.
|
||||
@@ -43,6 +43,7 @@ import org.springframework.web.util.pattern.PathPatternParser;
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Chris Bono
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
@@ -56,8 +57,8 @@ public class WebSocketIntegrationConfigurationInitializer implements Integration
|
||||
|
||||
@Override
|
||||
public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
if (beanFactory instanceof BeanDefinitionRegistry) {
|
||||
registerEnableWebSocketIfNecessary((BeanDefinitionRegistry) beanFactory);
|
||||
if (beanFactory instanceof BeanDefinitionRegistry beanDefinitionRegistry) {
|
||||
registerEnableWebSocketIfNecessary(beanDefinitionRegistry);
|
||||
}
|
||||
else {
|
||||
LOGGER.warn("'DelegatingWebSocketConfiguration' isn't registered because 'beanFactory'" +
|
||||
|
||||
@@ -66,6 +66,7 @@ import org.springframework.web.socket.messaging.SubProtocolHandler;
|
||||
* The {@link MessageProducerSupport} for inbound WebSocket messages.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
@@ -281,15 +282,15 @@ public class WebSocketInboundChannelAdapter extends MessageProducerSupport
|
||||
|
||||
@Override
|
||||
protected void doStart() {
|
||||
if (this.webSocketContainer instanceof Lifecycle) {
|
||||
((Lifecycle) this.webSocketContainer).start();
|
||||
if (this.webSocketContainer instanceof Lifecycle lifecycle) {
|
||||
lifecycle.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() {
|
||||
if (this.webSocketContainer instanceof Lifecycle) {
|
||||
((Lifecycle) this.webSocketContainer).stop();
|
||||
if (this.webSocketContainer instanceof Lifecycle lifecycle) {
|
||||
lifecycle.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -36,6 +36,7 @@ import org.springframework.ws.soap.SoapMessage;
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -73,8 +74,8 @@ public abstract class AbstractWebServiceInboundGateway extends MessagingGatewayS
|
||||
}
|
||||
catch (Exception e) {
|
||||
while ((e instanceof MessagingException || e instanceof ExpressionException) && // NOSONAR
|
||||
e.getCause() instanceof Exception) {
|
||||
e = (Exception) e.getCause();
|
||||
e.getCause() instanceof Exception exception) {
|
||||
e = exception;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
@@ -91,8 +92,7 @@ public abstract class AbstractWebServiceInboundGateway extends MessagingGatewayS
|
||||
builder.setHeader(propertyName, messageContext.getProperty(propertyName));
|
||||
}
|
||||
}
|
||||
if (request instanceof SoapMessage) {
|
||||
SoapMessage soapMessage = (SoapMessage) request;
|
||||
if (request instanceof SoapMessage soapMessage) {
|
||||
Map<String, ?> headers = this.headerMapper.toHeadersFromRequest(soapMessage);
|
||||
if (!CollectionUtils.isEmpty(headers)) {
|
||||
builder.copyHeaders(headers);
|
||||
@@ -101,9 +101,9 @@ public abstract class AbstractWebServiceInboundGateway extends MessagingGatewayS
|
||||
}
|
||||
|
||||
protected void toSoapHeaders(WebServiceMessage response, Message<?> replyMessage) {
|
||||
if (response instanceof SoapMessage) {
|
||||
if (response instanceof SoapMessage soapMessage) {
|
||||
this.headerMapper.fromHeadersToReply(
|
||||
replyMessage.getHeaders(), (SoapMessage) response);
|
||||
replyMessage.getHeaders(), soapMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ import org.springframework.xml.transform.TransformerObjectSupport;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyProducingMessageHandler {
|
||||
|
||||
@@ -206,8 +207,8 @@ public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyPro
|
||||
}
|
||||
Object responsePayload = doHandle(uriWithVariables.toString(), requestMessage, this.requestCallback);
|
||||
if (responsePayload != null && !(this.ignoreEmptyResponses
|
||||
&& responsePayload instanceof String
|
||||
&& !StringUtils.hasText((String) responsePayload))) {
|
||||
&& responsePayload instanceof String string
|
||||
&& !StringUtils.hasText(string))) {
|
||||
|
||||
return responsePayload;
|
||||
}
|
||||
@@ -247,9 +248,9 @@ public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyPro
|
||||
public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
|
||||
Object payload = this.requestMessage.getPayload();
|
||||
doWithMessageInternal(message, payload);
|
||||
if (message instanceof SoapMessage) {
|
||||
if (message instanceof SoapMessage soapMessage) {
|
||||
AbstractWebServiceOutboundGateway.this.headerMapper
|
||||
.fromHeadersToRequest(this.requestMessage.getHeaders(), (SoapMessage) message);
|
||||
.fromHeadersToRequest(this.requestMessage.getHeaders(), soapMessage);
|
||||
}
|
||||
if (this.reqCallback != null) {
|
||||
this.reqCallback.doWithMessage(message);
|
||||
@@ -270,9 +271,9 @@ public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyPro
|
||||
|
||||
Object resultObject = this.doExtractData(message);
|
||||
|
||||
if (resultObject != null && message instanceof SoapMessage) {
|
||||
if (resultObject != null && message instanceof SoapMessage soapMessage) {
|
||||
Map<String, Object> mappedMessageHeaders =
|
||||
AbstractWebServiceOutboundGateway.this.headerMapper.toHeadersFromReply((SoapMessage) message);
|
||||
AbstractWebServiceOutboundGateway.this.headerMapper.toHeadersFromReply(soapMessage);
|
||||
return getMessageBuilderFactory()
|
||||
.withPayload(resultObject)
|
||||
.copyHeaders(mappedMessageHeaders)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2023 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.
|
||||
@@ -39,6 +39,7 @@ import org.springframework.ws.server.endpoint.adapter.MessageEndpointAdapter;
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Chris Bono
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.3
|
||||
*
|
||||
@@ -53,12 +54,12 @@ public class WsIntegrationConfigurationInitializer implements IntegrationConfigu
|
||||
|
||||
@Override
|
||||
public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
if (beanFactory instanceof BeanDefinitionRegistry) {
|
||||
if (beanFactory instanceof BeanDefinitionRegistry beanDefinitionRegistry) {
|
||||
if (beanFactory.getBeanNamesForType(EndpointAdapter.class, false, false).length > 0) {
|
||||
BeanDefinitionBuilder requestMappingBuilder =
|
||||
BeanDefinitionBuilder.genericBeanDefinition(MessageEndpointAdapter.class)
|
||||
.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
((BeanDefinitionRegistry) beanFactory).registerBeanDefinition(MESSAGE_ENDPOINT_ADAPTER_BEAN_NAME,
|
||||
beanDefinitionRegistry.registerBeanDefinition(MESSAGE_ENDPOINT_ADAPTER_BEAN_NAME,
|
||||
requestMappingBuilder.getBeanDefinition());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -37,6 +37,7 @@ import org.springframework.xml.xpath.XPathExpressionFactory;
|
||||
* @author Jonas Partner
|
||||
* @author Soby Chacko
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class XPathExpressionParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
@@ -94,7 +95,7 @@ public class XPathExpressionParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
|
||||
if (prefixProvided) {
|
||||
Map<String, String> namespaceMap = new HashMap<String, String>(1);
|
||||
Map<String, String> namespaceMap = new HashMap<>(1);
|
||||
namespaceMap.put(nsPrefix, nsUri);
|
||||
builder.addConstructorArgValue(namespaceMap);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user