Apply "instanceof pattern matching" in spring-jms
This commit also applies additional clean-up tasks such as the following. - final fields This has only been applied to `src/main/java`.
This commit is contained in:
parent
971f665eb1
commit
d70a610a0d
|
@ -598,10 +598,9 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
|
|||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof ConsumerCacheKey)) {
|
||||
if (!(other instanceof ConsumerCacheKey otherKey)) {
|
||||
return false;
|
||||
}
|
||||
ConsumerCacheKey otherKey = (ConsumerCacheKey) other;
|
||||
return (destinationEquals(otherKey) &&
|
||||
ObjectUtils.nullSafeEquals(this.selector, otherKey.selector) &&
|
||||
ObjectUtils.nullSafeEquals(this.noLocal, otherKey.noLocal) &&
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
|
@ -232,10 +232,9 @@ public class UserCredentialsConnectionFactoryAdapter
|
|||
@Nullable String username, @Nullable String password) throws JMSException {
|
||||
|
||||
ConnectionFactory target = obtainTargetConnectionFactory();
|
||||
if (!(target instanceof QueueConnectionFactory)) {
|
||||
if (!(target instanceof QueueConnectionFactory queueFactory)) {
|
||||
throw new jakarta.jms.IllegalStateException("'targetConnectionFactory' is not a QueueConnectionFactory");
|
||||
}
|
||||
QueueConnectionFactory queueFactory = (QueueConnectionFactory) target;
|
||||
if (StringUtils.hasLength(username)) {
|
||||
return queueFactory.createQueueConnection(username, password);
|
||||
}
|
||||
|
@ -284,10 +283,9 @@ public class UserCredentialsConnectionFactoryAdapter
|
|||
@Nullable String username, @Nullable String password) throws JMSException {
|
||||
|
||||
ConnectionFactory target = obtainTargetConnectionFactory();
|
||||
if (!(target instanceof TopicConnectionFactory)) {
|
||||
if (!(target instanceof TopicConnectionFactory queueFactory)) {
|
||||
throw new jakarta.jms.IllegalStateException("'targetConnectionFactory' is not a TopicConnectionFactory");
|
||||
}
|
||||
TopicConnectionFactory queueFactory = (TopicConnectionFactory) target;
|
||||
if (StringUtils.hasLength(username)) {
|
||||
return queueFactory.createTopicConnection(username, password);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
|
@ -90,7 +90,7 @@ public abstract class AbstractPollingMessageListenerContainer extends AbstractMe
|
|||
@Nullable
|
||||
private PlatformTransactionManager transactionManager;
|
||||
|
||||
private DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition();
|
||||
private final DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition();
|
||||
|
||||
private long receiveTimeout = DEFAULT_RECEIVE_TIMEOUT;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
|
@ -411,8 +411,7 @@ public abstract class AbstractAdaptableMessageListener
|
|||
if (this.defaultResponseDestination instanceof Destination) {
|
||||
return (Destination) this.defaultResponseDestination;
|
||||
}
|
||||
if (this.defaultResponseDestination instanceof DestinationNameHolder) {
|
||||
DestinationNameHolder nameHolder = (DestinationNameHolder) this.defaultResponseDestination;
|
||||
if (this.defaultResponseDestination instanceof DestinationNameHolder nameHolder) {
|
||||
return getDestinationResolver().resolveDestinationName(session, nameHolder.name, nameHolder.isTopic);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
|
@ -94,8 +94,7 @@ public class JmsResponse<T> {
|
|||
if (this.destination instanceof Destination) {
|
||||
return (Destination) this.destination;
|
||||
}
|
||||
if (this.destination instanceof DestinationNameHolder) {
|
||||
DestinationNameHolder nameHolder = (DestinationNameHolder) this.destination;
|
||||
if (this.destination instanceof DestinationNameHolder nameHolder) {
|
||||
return destinationResolver.resolveDestinationName(session,
|
||||
nameHolder.destinationName, nameHolder.pubSubDomain);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
|
@ -114,11 +114,10 @@ public class QosSettings {
|
|||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof QosSettings)) {
|
||||
if (!(other instanceof QosSettings otherSettings)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QosSettings otherSettings = (QosSettings) other;
|
||||
return (this.deliveryMode == otherSettings.deliveryMode &&
|
||||
this.priority == otherSettings.priority &&
|
||||
this.timeToLive == otherSettings.timeToLive);
|
||||
|
|
|
@ -85,7 +85,7 @@ public class MappingJackson2MessageConverter implements SmartMessageConverter, B
|
|||
|
||||
private Map<String, Class<?>> idClassMappings = new HashMap<>();
|
||||
|
||||
private Map<Class<?>, String> classIdMappings = new HashMap<>();
|
||||
private final Map<Class<?>, String> classIdMappings = new HashMap<>();
|
||||
|
||||
@Nullable
|
||||
private ClassLoader beanClassLoader;
|
||||
|
@ -476,8 +476,7 @@ public class MappingJackson2MessageConverter implements SmartMessageConverter, B
|
|||
*/
|
||||
@Nullable
|
||||
protected Class<?> getSerializationView(@Nullable Object conversionHint) {
|
||||
if (conversionHint instanceof MethodParameter) {
|
||||
MethodParameter methodParam = (MethodParameter) conversionHint;
|
||||
if (conversionHint instanceof MethodParameter methodParam) {
|
||||
JsonView annotation = methodParam.getParameterAnnotation(JsonView.class);
|
||||
if (annotation == null) {
|
||||
annotation = methodParam.getMethodAnnotation(JsonView.class);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
|
@ -178,12 +178,10 @@ public class MarshallingMessageConverter implements MessageConverter, Initializi
|
|||
public Object fromMessage(Message message) throws JMSException, MessageConversionException {
|
||||
Assert.state(this.unmarshaller != null, "No Unmarshaller set");
|
||||
try {
|
||||
if (message instanceof TextMessage) {
|
||||
TextMessage textMessage = (TextMessage) message;
|
||||
if (message instanceof TextMessage textMessage) {
|
||||
return unmarshalFromTextMessage(textMessage, this.unmarshaller);
|
||||
}
|
||||
else if (message instanceof BytesMessage) {
|
||||
BytesMessage bytesMessage = (BytesMessage) message;
|
||||
else if (message instanceof BytesMessage bytesMessage) {
|
||||
return unmarshalFromBytesMessage(bytesMessage, this.unmarshaller);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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,7 +27,7 @@ import org.springframework.jms.support.SimpleJmsHeaderMapper;
|
|||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.core.AbstractMessagingTemplate;
|
||||
import org.springframework.messaging.core.AbstractMessageSendingTemplate;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class MessagingMessageConverter implements MessageConverter, Initializing
|
|||
}
|
||||
Message<?> input = (Message<?>) object;
|
||||
MessageHeaders headers = input.getHeaders();
|
||||
Object conversionHint = headers.get(AbstractMessagingTemplate.CONVERSION_HINT_HEADER);
|
||||
Object conversionHint = headers.get(AbstractMessageSendingTemplate.CONVERSION_HINT_HEADER);
|
||||
jakarta.jms.Message reply = createMessageForPayload(input.getPayload(), session, conversionHint);
|
||||
this.headerMapper.fromHeaders(headers, reply);
|
||||
return reply;
|
||||
|
|
Loading…
Reference in New Issue