Apply "instanceof pattern matching" in remainder of spring-messaging module

See gh-30067
This commit is contained in:
Sam Brannen 2023-03-06 16:23:10 +01:00
parent 09b60220d8
commit 004a144bdc
36 changed files with 160 additions and 174 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -333,9 +333,8 @@ public class MessageHeaders implements Map<String, Object>, Serializable {
// equals, hashCode, toString // equals, hashCode, toString
@Override @Override
public boolean equals(@Nullable Object other) { public boolean equals(@Nullable Object obj) {
return (this == other || return (this == obj || (obj instanceof MessageHeaders that && this.headers.equals(that.headers)));
(other instanceof MessageHeaders && this.headers.equals(((MessageHeaders) other).headers)));
} }
@Override @Override

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -69,8 +69,8 @@ public abstract class AbstractJsonMessageConverter extends AbstractMessageConver
if (ClassUtils.isAssignableValue(targetClass, payload)) { if (ClassUtils.isAssignableValue(targetClass, payload)) {
return payload; return payload;
} }
else if (payload instanceof byte[]) { else if (payload instanceof byte[] bytes) {
return fromJson(getReader((byte[]) payload, message.getHeaders()), resolvedType); return fromJson(getReader(bytes, message.getHeaders()), resolvedType);
} }
else { else {
// Assuming a text-based source payload // Assuming a text-based source payload

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -66,8 +66,8 @@ public class CompositeMessageConverter implements SmartMessageConverter {
@Nullable @Nullable
public Object fromMessage(Message<?> message, Class<?> targetClass, @Nullable Object conversionHint) { public Object fromMessage(Message<?> message, Class<?> targetClass, @Nullable Object conversionHint) {
for (MessageConverter converter : getConverters()) { for (MessageConverter converter : getConverters()) {
Object result = (converter instanceof SmartMessageConverter ? Object result = (converter instanceof SmartMessageConverter smartMessageConverter ?
((SmartMessageConverter) converter).fromMessage(message, targetClass, conversionHint) : smartMessageConverter.fromMessage(message, targetClass, conversionHint) :
converter.fromMessage(message, targetClass)); converter.fromMessage(message, targetClass));
if (result != null) { if (result != null) {
return result; return result;
@ -92,8 +92,8 @@ public class CompositeMessageConverter implements SmartMessageConverter {
@Nullable @Nullable
public Message<?> toMessage(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) { public Message<?> toMessage(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) {
for (MessageConverter converter : getConverters()) { for (MessageConverter converter : getConverters()) {
Message<?> result = (converter instanceof SmartMessageConverter ? Message<?> result = (converter instanceof SmartMessageConverter smartMessageConverter ?
((SmartMessageConverter) converter).toMessage(payload, headers, conversionHint) : smartMessageConverter.toMessage(payload, headers, conversionHint) :
converter.toMessage(payload, headers)); converter.toMessage(payload, headers));
if (result != null) { if (result != null) {
return result; return result;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -65,11 +65,11 @@ public class DefaultContentTypeResolver implements ContentTypeResolver {
if (value == null) { if (value == null) {
return null; return null;
} }
else if (value instanceof MimeType) { else if (value instanceof MimeType mimeType) {
return (MimeType) value; return mimeType;
} }
else if (value instanceof String) { else if (value instanceof String text) {
return MimeType.valueOf((String) value); return MimeType.valueOf(text);
} }
else { else {
throw new IllegalArgumentException( throw new IllegalArgumentException(

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -213,12 +213,12 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter {
if (ClassUtils.isAssignableValue(targetClass, payload)) { if (ClassUtils.isAssignableValue(targetClass, payload)) {
return payload; return payload;
} }
else if (payload instanceof byte[]) { else if (payload instanceof byte[] bytes) {
if (view != null) { if (view != null) {
return this.objectMapper.readerWithView(view).forType(javaType).readValue((byte[]) payload); return this.objectMapper.readerWithView(view).forType(javaType).readValue(bytes);
} }
else { else {
return this.objectMapper.readValue((byte[]) payload, javaType); return this.objectMapper.readValue(bytes, javaType);
} }
} }
else { else {
@ -290,11 +290,11 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter {
return extractViewClass(annotation, conversionHint); return extractViewClass(annotation, conversionHint);
} }
} }
else if (conversionHint instanceof JsonView) { else if (conversionHint instanceof JsonView jsonView) {
return extractViewClass((JsonView) conversionHint, conversionHint); return extractViewClass(jsonView, conversionHint);
} }
else if (conversionHint instanceof Class) { else if (conversionHint instanceof Class<?> clazz) {
return (Class<?>) conversionHint; return clazz;
} }
// No JSON view specified... // No JSON view specified...

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -86,8 +86,8 @@ public class MarshallingMessageConverter extends AbstractMessageConverter {
this(); this();
Assert.notNull(marshaller, "Marshaller must not be null"); Assert.notNull(marshaller, "Marshaller must not be null");
this.marshaller = marshaller; this.marshaller = marshaller;
if (marshaller instanceof Unmarshaller) { if (marshaller instanceof Unmarshaller _unmarshaller) {
this.unmarshaller = (Unmarshaller) marshaller; this.unmarshaller = _unmarshaller;
} }
} }
@ -159,8 +159,8 @@ public class MarshallingMessageConverter extends AbstractMessageConverter {
} }
private Source getSource(Object payload) { private Source getSource(Object payload) {
if (payload instanceof byte[]) { if (payload instanceof byte[] bytes) {
return new StreamSource(new ByteArrayInputStream((byte[]) payload)); return new StreamSource(new ByteArrayInputStream(bytes));
} }
else { else {
return new StreamSource(new StringReader(payload.toString())); return new StreamSource(new StringReader(payload.toString()));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -168,17 +168,13 @@ public abstract class AbstractMessageSendingTemplate<D> implements MessageSendin
Map<String, Object> headersToUse = processHeadersToSend(headers); Map<String, Object> headersToUse = processHeadersToSend(headers);
if (headersToUse != null) { if (headersToUse != null) {
if (headersToUse instanceof MessageHeaders) { messageHeaders = (headersToUse instanceof MessageHeaders _messageHeaders ?
messageHeaders = (MessageHeaders) headersToUse; _messageHeaders : new MessageHeaders(headersToUse));
}
else {
messageHeaders = new MessageHeaders(headersToUse);
}
} }
MessageConverter converter = getMessageConverter(); MessageConverter converter = getMessageConverter();
Message<?> message = (converter instanceof SmartMessageConverter ? Message<?> message = (converter instanceof SmartMessageConverter smartMessageConverter ?
((SmartMessageConverter) converter).toMessage(payload, messageHeaders, conversionHint) : smartMessageConverter.toMessage(payload, messageHeaders, conversionHint) :
converter.toMessage(payload, messageHeaders)); converter.toMessage(payload, messageHeaders));
if (message == null) { if (message == null) {
String payloadType = payload.getClass().getName(); String payloadType = payload.getClass().getName();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -201,10 +201,11 @@ public class GenericMessagingTemplate extends AbstractDestinationResolvingMessag
@Nullable @Nullable
protected final Message<?> doReceive(MessageChannel channel, long timeout) { protected final Message<?> doReceive(MessageChannel channel, long timeout) {
Assert.notNull(channel, "MessageChannel is required"); Assert.notNull(channel, "MessageChannel is required");
Assert.state(channel instanceof PollableChannel, "A PollableChannel is required to receive messages"); if (!(channel instanceof PollableChannel pollableChannel)) {
throw new IllegalStateException("A PollableChannel is required to receive messages");
}
Message<?> message = (timeout >= 0 ? Message<?> message = (timeout >= 0 ? pollableChannel.receive(timeout) : pollableChannel.receive());
((PollableChannel) channel).receive(timeout) : ((PollableChannel) channel).receive());
if (message == null && logger.isTraceEnabled()) { if (message == null && logger.isTraceEnabled()) {
logger.trace("Failed to receive message from channel '" + channel + "' within timeout: " + timeout); logger.trace("Failed to receive message from channel '" + channel + "' within timeout: " + timeout);
@ -260,11 +261,11 @@ public class GenericMessagingTemplate extends AbstractDestinationResolvingMessag
@Nullable @Nullable
private Long headerToLong(@Nullable Object headerValue) { private Long headerToLong(@Nullable Object headerValue) {
if (headerValue instanceof Number) { if (headerValue instanceof Number number) {
return ((Number) headerValue).longValue(); return number.longValue();
} }
else if (headerValue instanceof String) { else if (headerValue instanceof String text) {
return Long.parseLong((String) headerValue); return Long.parseLong(text);
} }
else { else {
return null; return null;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -188,14 +188,12 @@ public class DestinationPatternsMessageCondition
} }
private boolean matchPattern(String pattern, Object destination) { private boolean matchPattern(String pattern, Object destination) {
return destination instanceof RouteMatcher.Route ? return destination instanceof RouteMatcher.Route route ? this.routeMatcher.match(pattern, route) :
this.routeMatcher.match(pattern, (RouteMatcher.Route) destination) :
((SimpleRouteMatcher) this.routeMatcher).getPathMatcher().match(pattern, (String) destination); ((SimpleRouteMatcher) this.routeMatcher).getPathMatcher().match(pattern, (String) destination);
} }
private Comparator<String> getPatternComparator(Object destination) { private Comparator<String> getPatternComparator(Object destination) {
return destination instanceof RouteMatcher.Route ? return destination instanceof RouteMatcher.Route route ? this.routeMatcher.getPatternComparator(route) :
this.routeMatcher.getPatternComparator((RouteMatcher.Route) destination) :
((SimpleRouteMatcher) this.routeMatcher).getPathMatcher().getPatternComparator((String) destination); ((SimpleRouteMatcher) this.routeMatcher).getPathMatcher().getPatternComparator((String) destination);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -242,8 +242,8 @@ public class MessageMappingMessageHandler extends AbstractMethodMessageHandler<C
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>(); List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>();
ApplicationContext context = getApplicationContext(); ApplicationContext context = getApplicationContext();
ConfigurableBeanFactory beanFactory = (context instanceof ConfigurableApplicationContext ? ConfigurableBeanFactory beanFactory = (context instanceof ConfigurableApplicationContext cac ?
((ConfigurableApplicationContext) context).getBeanFactory() : null); cac.getBeanFactory() : null);
// Annotation-based resolvers // Annotation-based resolvers
resolvers.add(new HeaderMethodArgumentResolver(this.conversionService, beanFactory)); resolvers.add(new HeaderMethodArgumentResolver(this.conversionService, beanFactory));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -157,8 +157,8 @@ public class DefaultMessageHandlerMethodFactory
protected List<HandlerMethodArgumentResolver> initArgumentResolvers() { protected List<HandlerMethodArgumentResolver> initArgumentResolvers() {
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>(); List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>();
ConfigurableBeanFactory beanFactory = (this.beanFactory instanceof ConfigurableBeanFactory ? ConfigurableBeanFactory beanFactory = (this.beanFactory instanceof ConfigurableBeanFactory cbf ?
(ConfigurableBeanFactory) this.beanFactory : null); cbf : null);
// Annotation-based argument resolution // Annotation-based argument resolution
resolvers.add(new HeaderMethodArgumentResolver(this.conversionService, beanFactory)); resolvers.add(new HeaderMethodArgumentResolver(this.conversionService, beanFactory));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -121,11 +121,11 @@ public class MessageMethodArgumentResolver implements HandlerMethodArgumentResol
if (payload == null) { if (payload == null) {
return true; return true;
} }
else if (payload instanceof byte[]) { else if (payload instanceof byte[] bytes) {
return ((byte[]) payload).length == 0; return bytes.length == 0;
} }
else if (payload instanceof String) { else if (payload instanceof String text) {
return !StringUtils.hasText((String) payload); return !StringUtils.hasText(text);
} }
else { else {
return false; return false;

View File

@ -299,10 +299,10 @@ public abstract class AbstractMethodMessageHandler<T>
*/ */
protected final void detectHandlerMethods(final Object handler) { protected final void detectHandlerMethods(final Object handler) {
Class<?> handlerType; Class<?> handlerType;
if (handler instanceof String) { if (handler instanceof String beanName) {
ApplicationContext context = getApplicationContext(); ApplicationContext context = getApplicationContext();
Assert.state(context != null, "ApplicationContext is required for resolving handler bean names"); Assert.state(context != null, "ApplicationContext is required for resolving handler bean names");
handlerType = context.getType((String) handler); handlerType = context.getType(beanName);
} }
else { else {
handlerType = handler.getClass(); handlerType = handler.getClass();
@ -730,8 +730,9 @@ public abstract class AbstractMethodMessageHandler<T>
} }
} }
private void handleFailure(Throwable ex) { private void handleFailure(Throwable throwable) {
Exception cause = (ex instanceof Exception ? (Exception) ex : new IllegalStateException(ex)); Exception cause = (throwable instanceof Exception exception ? exception :
new IllegalStateException(throwable));
processHandlerMethodException(this.handlerMethod, cause, this.message); processHandlerMethodException(this.handlerMethod, cause, this.message);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -177,14 +177,14 @@ public class InvocableHandlerMethod extends HandlerMethod {
catch (InvocationTargetException ex) { catch (InvocationTargetException ex) {
// Unwrap for HandlerExceptionResolvers ... // Unwrap for HandlerExceptionResolvers ...
Throwable targetException = ex.getTargetException(); Throwable targetException = ex.getTargetException();
if (targetException instanceof RuntimeException) { if (targetException instanceof RuntimeException runtimeException) {
throw (RuntimeException) targetException; throw runtimeException;
} }
else if (targetException instanceof Error) { else if (targetException instanceof Error error) {
throw (Error) targetException; throw error;
} }
else if (targetException instanceof Exception) { else if (targetException instanceof Exception exception) {
throw (Exception) targetException; throw exception;
} }
else { else {
throw new IllegalStateException(formatInvokeError("Invocation failure", args), targetException); throw new IllegalStateException(formatInvokeError("Invocation failure", args), targetException);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -322,10 +322,10 @@ public abstract class AbstractMethodMessageHandler<T>
*/ */
protected final void detectHandlerMethods(Object handler) { protected final void detectHandlerMethods(Object handler) {
Class<?> handlerType; Class<?> handlerType;
if (handler instanceof String) { if (handler instanceof String handlerName) {
ApplicationContext context = getApplicationContext(); ApplicationContext context = getApplicationContext();
Assert.state(context != null, "ApplicationContext is required for resolving handler bean names"); Assert.state(context != null, "ApplicationContext is required for resolving handler bean names");
handlerType = context.getType((String) handler); handlerType = context.getType(handlerName);
} }
else { else {
handlerType = handler.getClass(); handlerType = handler.getClass();
@ -404,11 +404,10 @@ public abstract class AbstractMethodMessageHandler<T>
*/ */
private HandlerMethod createHandlerMethod(Object handler, Method method) { private HandlerMethod createHandlerMethod(Object handler, Method method) {
HandlerMethod handlerMethod; HandlerMethod handlerMethod;
if (handler instanceof String) { if (handler instanceof String handlerName) {
ApplicationContext context = getApplicationContext(); ApplicationContext context = getApplicationContext();
Assert.state(context != null, "ApplicationContext is required for resolving handler bean names"); Assert.state(context != null, "ApplicationContext is required for resolving handler bean names");
String beanName = (String) handler; handlerMethod = new HandlerMethod(handlerName, context.getAutowireCapableBeanFactory(), method);
handlerMethod = new HandlerMethod(beanName, context.getAutowireCapableBeanFactory(), method);
} }
else { else {
handlerMethod = new HandlerMethod(handler, method); handlerMethod = new HandlerMethod(handler, method);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -196,8 +196,8 @@ final class DefaultRSocketRequester implements RSocketRequester {
private void createPayload(Object input, ResolvableType elementType) { private void createPayload(Object input, ResolvableType elementType) {
ReactiveAdapter adapter = getAdapter(input.getClass()); ReactiveAdapter adapter = getAdapter(input.getClass());
Publisher<?> publisher; Publisher<?> publisher;
if (input instanceof Publisher) { if (input instanceof Publisher<?> _publisher) {
publisher = (Publisher<?>) input; publisher = _publisher;
} }
else if (adapter != null) { else if (adapter != null) {
publisher = adapter.toPublisher(input); publisher = adapter.toPublisher(input);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -222,8 +222,8 @@ final class DefaultRSocketStrategies implements RSocketStrategies {
MetadataExtractor extractor = (this.metadataExtractor != null ? MetadataExtractor extractor = (this.metadataExtractor != null ?
this.metadataExtractor : new DefaultMetadataExtractor(this.decoders)); this.metadataExtractor : new DefaultMetadataExtractor(this.decoders));
if (extractor instanceof MetadataExtractorRegistry) { if (extractor instanceof MetadataExtractorRegistry metadataExtractorRegistry) {
this.metadataExtractors.forEach(consumer -> consumer.accept((MetadataExtractorRegistry) extractor)); this.metadataExtractors.forEach(consumer -> consumer.accept(metadataExtractorRegistry));
} }
return new DefaultRSocketStrategies( return new DefaultRSocketStrategies(

View File

@ -50,9 +50,9 @@ public abstract class PayloadUtils {
*/ */
public static DataBuffer retainDataAndReleasePayload(Payload payload, DataBufferFactory bufferFactory) { public static DataBuffer retainDataAndReleasePayload(Payload payload, DataBufferFactory bufferFactory) {
try { try {
if (bufferFactory instanceof NettyDataBufferFactory) { if (bufferFactory instanceof NettyDataBufferFactory nettyBufferFactory) {
ByteBuf byteBuf = payload.sliceData().retain(); ByteBuf byteBuf = payload.sliceData().retain();
return ((NettyDataBufferFactory) bufferFactory).wrap(byteBuf); return nettyBufferFactory.wrap(byteBuf);
} }
else { else {
return bufferFactory.wrap(payload.getData()); return bufferFactory.wrap(payload.getData());

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -156,8 +156,8 @@ class MessagingRSocket implements RSocket {
} }
private int refCount(DataBuffer dataBuffer) { private int refCount(DataBuffer dataBuffer) {
return dataBuffer instanceof NettyDataBuffer ? return dataBuffer instanceof NettyDataBuffer nettyDataBuffer ?
((NettyDataBuffer) dataBuffer).getNativeBuffer().refCnt() : 1; nettyDataBuffer.getNativeBuffer().refCnt() : 1;
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -484,7 +484,7 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
Assert.notEmpty(candidateHandlers, "No handlers"); Assert.notEmpty(candidateHandlers, "No handlers");
List<Object> handlers = new ArrayList<>(candidateHandlers.length); List<Object> handlers = new ArrayList<>(candidateHandlers.length);
for (Object obj : candidateHandlers) { for (Object obj : candidateHandlers) {
handlers.add(obj instanceof Class ? BeanUtils.instantiateClass((Class<?>) obj) : obj); handlers.add(obj instanceof Class<?> clazz ? BeanUtils.instantiateClass(clazz) : obj);
} }
RSocketMessageHandler handler = new RSocketMessageHandler(); RSocketMessageHandler handler = new RSocketMessageHandler();
handler.setHandlers(handlers); handler.setHandlers(handlers);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -44,8 +44,8 @@ public class DestinationVariableArgumentResolver implements RSocketServiceArgume
} }
if (argument != null) { if (argument != null) {
if (argument instanceof Collection) { if (argument instanceof Collection<?> collection) {
((Collection<?>) argument).forEach(requestValues::addRouteVariable); collection.forEach(requestValues::addRouteVariable);
return true; return true;
} }
else if (argument.getClass().isArray()) { else if (argument.getClass().isArray()) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -77,14 +77,8 @@ public class SimpMessageMappingInfo implements MessageCondition<SimpMessageMappi
@Override @Override
public boolean equals(@Nullable Object other) { public boolean equals(@Nullable Object obj) {
if (this == other) { return (this == obj) || (obj instanceof SimpMessageMappingInfo that && this.delegate.equals(that.delegate));
return true;
}
if (!(other instanceof SimpMessageMappingInfo)) {
return false;
}
return this.delegate.equals(((SimpMessageMappingInfo) other).delegate);
} }
@Override @Override

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -255,9 +255,9 @@ public class SimpMessagingTemplate extends AbstractMessageSendingTemplate<String
if (headers.containsKey(NativeMessageHeaderAccessor.NATIVE_HEADERS)) { if (headers.containsKey(NativeMessageHeaderAccessor.NATIVE_HEADERS)) {
return headers; return headers;
} }
if (headers instanceof MessageHeaders) { if (headers instanceof MessageHeaders messageHeaders) {
SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor accessor =
MessageHeaderAccessor.getAccessor((MessageHeaders) headers, SimpMessageHeaderAccessor.class); MessageHeaderAccessor.getAccessor(messageHeaders, SimpMessageHeaderAccessor.class);
if (accessor != null) { if (accessor != null) {
return headers; return headers;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -212,8 +212,8 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH
protected String getUserName(Message<?> message, MessageHeaders headers) { protected String getUserName(Message<?> message, MessageHeaders headers) {
Principal principal = SimpMessageHeaderAccessor.getUser(headers); Principal principal = SimpMessageHeaderAccessor.getUser(headers);
if (principal != null) { if (principal != null) {
return (principal instanceof DestinationUserNameProvider ? return (principal instanceof DestinationUserNameProvider provider ?
((DestinationUserNameProvider) principal).getDestinationUserName() : principal.getName()); provider.getDestinationUserName() : principal.getName());
} }
return null; return null;
} }

View File

@ -305,8 +305,8 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
@Override @Override
protected List<HandlerMethodArgumentResolver> initArgumentResolvers() { protected List<HandlerMethodArgumentResolver> initArgumentResolvers() {
ApplicationContext context = getApplicationContext(); ApplicationContext context = getApplicationContext();
ConfigurableBeanFactory beanFactory = (context instanceof ConfigurableApplicationContext ? ConfigurableBeanFactory beanFactory = (context instanceof ConfigurableApplicationContext cac ?
((ConfigurableApplicationContext) context).getBeanFactory() : null); cac.getBeanFactory() : null);
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>(); List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -205,8 +205,8 @@ public abstract class AbstractBrokerMessageHandler
logger.info("Starting..."); logger.info("Starting...");
this.clientInboundChannel.subscribe(this); this.clientInboundChannel.subscribe(this);
this.brokerChannel.subscribe(this); this.brokerChannel.subscribe(this);
if (this.clientInboundChannel instanceof InterceptableChannel) { if (this.clientInboundChannel instanceof InterceptableChannel ic) {
((InterceptableChannel) this.clientInboundChannel).addInterceptor(0, this.unsentDisconnectInterceptor); ic.addInterceptor(0, this.unsentDisconnectInterceptor);
} }
startInternal(); startInternal();
this.running = true; this.running = true;
@ -224,8 +224,8 @@ public abstract class AbstractBrokerMessageHandler
stopInternal(); stopInternal();
this.clientInboundChannel.unsubscribe(this); this.clientInboundChannel.unsubscribe(this);
this.brokerChannel.unsubscribe(this); this.brokerChannel.unsubscribe(this);
if (this.clientInboundChannel instanceof InterceptableChannel) { if (this.clientInboundChannel instanceof InterceptableChannel ic) {
((InterceptableChannel) this.clientInboundChannel).removeInterceptor(this.unsentDisconnectInterceptor); ic.removeInterceptor(this.unsentDisconnectInterceptor);
} }
this.running = false; this.running = false;
logger.info("Stopped."); logger.info("Stopped.");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -474,9 +474,8 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
} }
@Override @Override
public boolean equals(@Nullable Object other) { public boolean equals(@Nullable Object obj) {
return (this == other || return (this == obj || (obj instanceof Subscription that && this.id.equals(that.id)));
(other instanceof Subscription && this.id.equals(((Subscription) other).id)));
} }
@Override @Override
@ -507,8 +506,8 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public TypedValue read(EvaluationContext context, @Nullable Object target, String name) { public TypedValue read(EvaluationContext context, @Nullable Object target, String name) {
Object value; Object value;
if (target instanceof Message) { if (target instanceof Message message) {
value = name.equals("headers") ? ((Message) target).getHeaders() : null; value = name.equals("headers") ? message.getHeaders() : null;
} }
else if (target instanceof MessageHeaders headers) { else if (target instanceof MessageHeaders headers) {
SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor accessor =

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -150,12 +150,12 @@ public class OrderedMessageChannelDecorator implements MessageChannel {
Assert.isInstanceOf(ExecutorSubscribableChannel.class, channel, Assert.isInstanceOf(ExecutorSubscribableChannel.class, channel,
"An ExecutorSubscribableChannel is required for 'preservePublishOrder'"); "An ExecutorSubscribableChannel is required for 'preservePublishOrder'");
ExecutorSubscribableChannel execChannel = (ExecutorSubscribableChannel) channel; ExecutorSubscribableChannel execChannel = (ExecutorSubscribableChannel) channel;
if (execChannel.getInterceptors().stream().noneMatch(i -> i instanceof CallbackInterceptor)) { if (execChannel.getInterceptors().stream().noneMatch(CallbackInterceptor.class::isInstance)) {
execChannel.addInterceptor(0, new CallbackInterceptor()); execChannel.addInterceptor(0, new CallbackInterceptor());
} }
} }
else if (channel instanceof ExecutorSubscribableChannel execChannel) { else if (channel instanceof ExecutorSubscribableChannel execChannel) {
execChannel.getInterceptors().stream().filter(i -> i instanceof CallbackInterceptor) execChannel.getInterceptors().stream().filter(CallbackInterceptor.class::isInstance)
.findFirst().map(execChannel::removeInterceptor); .findFirst().map(execChannel::removeInterceptor);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -130,8 +130,8 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler {
} }
private void initPathMatcherToUse() { private void initPathMatcherToUse() {
if (this.pathMatcher != null && this.subscriptionRegistry instanceof DefaultSubscriptionRegistry) { if (this.pathMatcher != null && this.subscriptionRegistry instanceof DefaultSubscriptionRegistry defaultRegistry) {
((DefaultSubscriptionRegistry) this.subscriptionRegistry).setPathMatcher(this.pathMatcher); defaultRegistry.setPathMatcher(this.pathMatcher);
} }
} }
@ -151,8 +151,8 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler {
} }
private void initCacheLimitToUse() { private void initCacheLimitToUse() {
if (this.cacheLimit != null && this.subscriptionRegistry instanceof DefaultSubscriptionRegistry) { if (this.cacheLimit != null && this.subscriptionRegistry instanceof DefaultSubscriptionRegistry defaultRegistry) {
((DefaultSubscriptionRegistry) this.subscriptionRegistry).setCacheLimit(this.cacheLimit); defaultRegistry.setCacheLimit(this.cacheLimit);
} }
} }
@ -178,8 +178,8 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler {
} }
private void initSelectorHeaderNameToUse() { private void initSelectorHeaderNameToUse() {
if (this.subscriptionRegistry instanceof DefaultSubscriptionRegistry) { if (this.subscriptionRegistry instanceof DefaultSubscriptionRegistry defaultRegistry) {
((DefaultSubscriptionRegistry) this.subscriptionRegistry).setSelectorHeaderName(this.selectorHeaderName); defaultRegistry.setSelectorHeaderName(this.selectorHeaderName);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -534,7 +534,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
return; return;
} }
StompHeaderAccessor stompAccessor; StompHeaderAccessor stompHeaderAccessor;
StompCommand command; StompCommand command;
MessageHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class); MessageHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class);
@ -542,15 +542,15 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
throw new IllegalStateException( throw new IllegalStateException(
"No header accessor (not using the SimpMessagingTemplate?): " + message); "No header accessor (not using the SimpMessagingTemplate?): " + message);
} }
else if (accessor instanceof StompHeaderAccessor) { else if (accessor instanceof StompHeaderAccessor _stompHeaderAccessor) {
stompAccessor = (StompHeaderAccessor) accessor; stompHeaderAccessor = _stompHeaderAccessor;
command = stompAccessor.getCommand(); command = stompHeaderAccessor.getCommand();
} }
else if (accessor instanceof SimpMessageHeaderAccessor) { else if (accessor instanceof SimpMessageHeaderAccessor) {
stompAccessor = StompHeaderAccessor.wrap(message); stompHeaderAccessor = StompHeaderAccessor.wrap(message);
command = stompAccessor.getCommand(); command = stompHeaderAccessor.getCommand();
if (command == null) { if (command == null) {
command = stompAccessor.updateStompCommandAsClientMessage(); command = stompHeaderAccessor.updateStompCommandAsClientMessage();
} }
} }
else { else {
@ -559,14 +559,14 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
} }
if (sessionId == null) { if (sessionId == null) {
if (!SimpMessageType.MESSAGE.equals(stompAccessor.getMessageType())) { if (!SimpMessageType.MESSAGE.equals(stompHeaderAccessor.getMessageType())) {
if (logger.isErrorEnabled()) { if (logger.isErrorEnabled()) {
logger.error("Only STOMP SEND supported from within the server side. Ignoring " + message); logger.error("Only STOMP SEND supported from within the server side. Ignoring " + message);
} }
return; return;
} }
sessionId = SYSTEM_SESSION_ID; sessionId = SYSTEM_SESSION_ID;
stompAccessor.setSessionId(sessionId); stompHeaderAccessor.setSessionId(sessionId);
} }
if (StompCommand.CONNECT.equals(command) || StompCommand.STOMP.equals(command)) { if (StompCommand.CONNECT.equals(command) || StompCommand.STOMP.equals(command)) {
@ -577,15 +577,15 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
return; return;
} }
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug(stompAccessor.getShortLogMessage(EMPTY_PAYLOAD)); logger.debug(stompHeaderAccessor.getShortLogMessage(EMPTY_PAYLOAD));
} }
stompAccessor = (stompAccessor.isMutable() ? stompAccessor : StompHeaderAccessor.wrap(message)); stompHeaderAccessor = (stompHeaderAccessor.isMutable() ? stompHeaderAccessor : StompHeaderAccessor.wrap(message));
stompAccessor.setLogin(this.clientLogin); stompHeaderAccessor.setLogin(this.clientLogin);
stompAccessor.setPasscode(this.clientPasscode); stompHeaderAccessor.setPasscode(this.clientPasscode);
if (getVirtualHost() != null) { if (getVirtualHost() != null) {
stompAccessor.setHost(getVirtualHost()); stompHeaderAccessor.setHost(getVirtualHost());
} }
RelayConnectionHandler handler = new RelayConnectionHandler(sessionId, stompAccessor); RelayConnectionHandler handler = new RelayConnectionHandler(sessionId, stompHeaderAccessor);
this.connectionHandlers.put(sessionId, handler); this.connectionHandlers.put(sessionId, handler);
this.stats.incrementConnectCount(); this.stats.incrementConnectCount();
Assert.state(this.tcpClient != null, "No TCP client available"); Assert.state(this.tcpClient != null, "No TCP client available");
@ -600,7 +600,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
return; return;
} }
this.stats.incrementDisconnectCount(); this.stats.incrementDisconnectCount();
handler.forward(message, stompAccessor); handler.forward(message, stompHeaderAccessor);
} }
else { else {
RelayConnectionHandler handler = this.connectionHandlers.get(sessionId); RelayConnectionHandler handler = this.connectionHandlers.get(sessionId);
@ -611,7 +611,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
return; return;
} }
String destination = stompAccessor.getDestination(); String destination = stompHeaderAccessor.getDestination();
if (command != null && command.requiresDestination() && !checkDestinationPrefix(destination)) { if (command != null && command.requiresDestination() && !checkDestinationPrefix(destination)) {
// Not a broker destination but send a heartbeat to keep the connection // Not a broker destination but send a heartbeat to keep the connection
if (handler.shouldSendHeartbeatForIgnoredMessage()) { if (handler.shouldSendHeartbeatForIgnoredMessage()) {
@ -620,7 +620,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
return; return;
} }
handler.forward(message, stompAccessor); handler.forward(message, stompHeaderAccessor);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -554,9 +554,8 @@ public class StompHeaders implements MultiValueMap<String, String>, Serializable
@Override @Override
public boolean equals(@Nullable Object other) { public boolean equals(@Nullable Object obj) {
return (this == other || (other instanceof StompHeaders && return (this == obj || (obj instanceof StompHeaders that && this.headers.equals(that.headers)));
this.headers.equals(((StompHeaders) other).headers)));
} }
@Override @Override

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -369,8 +369,8 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
@Override @Override
public boolean equals(@Nullable Object other) { public boolean equals(@Nullable Object obj) {
return (this == other || (other instanceof SimpUser && this.name.equals(((SimpUser) other).getName()))); return (this == obj || (obj instanceof SimpUser that && this.name.equals(that.getName())));
} }
@Override @Override
@ -455,8 +455,8 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
} }
@Override @Override
public boolean equals(@Nullable Object other) { public boolean equals(@Nullable Object obj) {
return (this == other || (other instanceof SimpSession && getId().equals(((SimpSession) other).getId()))); return (this == obj || (obj instanceof SimpSession that && this.id.equals(that.getId())));
} }
@Override @Override

View File

@ -143,8 +143,8 @@ public abstract class AbstractMessageChannel implements MessageChannel, Intercep
} }
catch (Exception ex) { catch (Exception ex) {
chain.triggerAfterSendCompletion(messageToUse, this, sent, ex); chain.triggerAfterSendCompletion(messageToUse, this, sent, ex);
if (ex instanceof MessagingException) { if (ex instanceof MessagingException messagingException) {
throw (MessagingException) ex; throw messagingException;
} }
throw new MessageDeliveryException(messageToUse,"Failed to send message to " + this, ex); throw new MessageDeliveryException(messageToUse,"Failed to send message to " + this, ex);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -86,8 +86,8 @@ public class ExecutorSubscribableChannel extends AbstractSubscribableChannel {
} }
private void updateExecutorInterceptorsFor(ChannelInterceptor interceptor) { private void updateExecutorInterceptorsFor(ChannelInterceptor interceptor) {
if (interceptor instanceof ExecutorChannelInterceptor) { if (interceptor instanceof ExecutorChannelInterceptor executorChannelInterceptor) {
this.executorInterceptors.add((ExecutorChannelInterceptor) interceptor); this.executorInterceptors.add(executorChannelInterceptor);
} }
} }
@ -146,8 +146,8 @@ public class ExecutorSubscribableChannel extends AbstractSubscribableChannel {
} }
catch (Exception ex) { catch (Exception ex) {
triggerAfterMessageHandled(message, ex); triggerAfterMessageHandled(message, ex);
if (ex instanceof MessagingException) { if (ex instanceof MessagingException messagingException) {
throw (MessagingException) ex; throw messagingException;
} }
String description = "Failed to handle " + message + " to " + this + " in " + this.messageHandler; String description = "Failed to handle " + message + " to " + this + " in " + this.messageHandler;
throw new MessageDeliveryException(message, description, ex); throw new MessageDeliveryException(message, description, ex);

View File

@ -110,8 +110,8 @@ public class GenericMessage<T> implements Message<T>, Serializable {
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(getClass().getSimpleName()); StringBuilder sb = new StringBuilder(getClass().getSimpleName());
sb.append(" [payload="); sb.append(" [payload=");
if (this.payload instanceof byte[]) { if (this.payload instanceof byte[] bytes) {
sb.append("byte[").append(((byte[]) this.payload).length).append(']'); sb.append("byte[").append(bytes.length).append(']');
} }
else { else {
sb.append(this.payload); sb.append(this.payload);

View File

@ -416,7 +416,7 @@ public class MessageHeaderAccessor {
if (value == null) { if (value == null) {
return null; return null;
} }
return (value instanceof UUID ? (UUID) value : UUID.fromString(value.toString())); return (value instanceof UUID uuid ? uuid : UUID.fromString(value.toString()));
} }
@Nullable @Nullable
@ -425,7 +425,7 @@ public class MessageHeaderAccessor {
if (value == null) { if (value == null) {
return null; return null;
} }
return (value instanceof Long ? (Long) value : Long.parseLong(value.toString())); return (value instanceof Long num ? num : Long.parseLong(value.toString()));
} }
public void setContentType(MimeType contentType) { public void setContentType(MimeType contentType) {
@ -438,7 +438,7 @@ public class MessageHeaderAccessor {
if (value == null) { if (value == null) {
return null; return null;
} }
return (value instanceof MimeType ? (MimeType) value : MimeType.valueOf(value.toString())); return (value instanceof MimeType mimeType ? mimeType : MimeType.valueOf(value.toString()));
} }
private Charset getCharset() { private Charset getCharset() {