Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
*
*
* @author Artem Bilan
* @author Glenn Renfro
*
* @since 5.2
*/
Expand Down Expand Up @@ -84,6 +85,7 @@ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
@Override
public Object processMessageGroup(MessageGroup group) {
Object result = this.delegate.processMessageGroup(group);
Assert.state(result != null, "The delegate must return a non-null for the group");
if (!(result instanceof Message<?>) && !(result instanceof AbstractIntegrationMessageBuilder)) {
result = getMessageBuilderFactory()
.withPayload(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected Object doTransform(Message<?> message) {
catch (IOException e) {
throw new UncheckedIOException(e);
}

Assert.state(result != null, "Payload result must not be null");
if (removeHeaders) {
return getMessageBuilderFactory()
.withPayload(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.io.UncheckedIOException;
import java.util.Map;

import org.jspecify.annotations.Nullable;

import org.springframework.integration.support.json.JsonObjectMapper;
import org.springframework.integration.support.json.JsonObjectMapperProvider;
import org.springframework.integration.transformer.AbstractTransformer;
Expand Down Expand Up @@ -114,7 +116,7 @@ public String getComponentType() {
@Override
protected Object doTransform(Message<?> message) {
Object payload = buildJsonPayload(message.getPayload());

Assert.state(payload != null, "Payload result must not be null");
Map<String, Object> headers = new LinkedCaseInsensitiveMap<>();
headers.putAll(message.getHeaders());

Expand All @@ -136,7 +138,7 @@ else if (StringUtils.hasLength(this.contentType)) {
.build();
}

private Object buildJsonPayload(Object payload) {
private @Nullable Object buildJsonPayload(Object payload) {
try {
switch (this.resultType) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package org.springframework.integration.leader.event;

import org.jspecify.annotations.Nullable;

import org.springframework.context.ApplicationEvent;
import org.springframework.integration.leader.Context;

Expand All @@ -32,18 +30,9 @@
@SuppressWarnings("serial")
public abstract class AbstractLeaderEvent extends ApplicationEvent {

private final @Nullable Context context;

private final @Nullable String role;
private final Context context;

/**
* Create a new ApplicationEvent.
*
* @param source the component that published the event (never {@code null})
*/
public AbstractLeaderEvent(Object source) {
this(source, null, null);
}
private final String role;

/**
* Create a new ApplicationEvent.
Expand All @@ -52,7 +41,7 @@ public AbstractLeaderEvent(Object source) {
* @param context the context associated with this event
* @param role the role of the leader
*/
public AbstractLeaderEvent(Object source, @Nullable Context context, @Nullable String role) {
public AbstractLeaderEvent(Object source, Context context, String role) {
super(source);
this.context = context;
this.role = role;
Expand All @@ -63,7 +52,7 @@ public AbstractLeaderEvent(Object source, @Nullable Context context, @Nullable S
*
* @return the context
*/
public @Nullable Context getContext() {
public Context getContext() {
return this.context;
}

Expand All @@ -72,7 +61,7 @@ public AbstractLeaderEvent(Object source, @Nullable Context context, @Nullable S
*
* @return the role
*/
public @Nullable String getRole() {
public String getRole() {
return this.role;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ else if (result instanceof Publisher<?> publisher) {
Map<String, Object> headers = messageHeaders;
Object correlationId = message.getHeaders().getId();
AtomicInteger sequenceNumber = new AtomicInteger(1);

return object -> createBuilder(object, headers, correlationId, sequenceNumber.getAndIncrement(), sequenceSize);
}

Expand Down Expand Up @@ -282,6 +281,7 @@ private AbstractIntegrationMessageBuilder<?> createBuilder(Object item, Map<Stri
.cloneMessageHistoryIfAny();

if (this.applySequence) {
Assert.state(correlationId != null, "Correlation ID must not be null.");
builder.pushSequenceDetails(correlationId, sequenceNumber, sequenceSize);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.springframework.messaging.support.ErrorMessage;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;

/**
* The {@link AbstractIntegrationMessageBuilder} extension for the default logic to build message.
Expand All @@ -48,6 +47,7 @@
* @param <B> the target builder class type.
*
* @author Artem Bilan
* @author Glenn Renfro
*
* @since 6.4
*
Expand All @@ -63,12 +63,11 @@ public abstract class BaseMessageBuilder<T, B extends BaseMessageBuilder<T, B>>

private final IntegrationMessageHeaderAccessor headerAccessor;

@Nullable
private final Message<T> originalMessage;
private final @Nullable Message<T> originalMessage;

private volatile boolean modified;

private String[] readOnlyHeaders;
private String @Nullable [] readOnlyHeaders;

protected BaseMessageBuilder(T payload, @Nullable Message<T> originalMessage) {
Assert.notNull(payload, "payload must not be null");
Expand Down Expand Up @@ -285,7 +284,7 @@ public B setPriority(Integer priority) {
* @return the current {@link BaseMessageBuilder}
* @see IntegrationMessageHeaderAccessor#isReadOnly(String)
*/
public B readOnlyHeaders(@Nullable String... readOnlyHeaders) {
public B readOnlyHeaders(String @Nullable ... readOnlyHeaders) {
this.readOnlyHeaders = readOnlyHeaders != null ? Arrays.copyOf(readOnlyHeaders, readOnlyHeaders.length) : null;
if (readOnlyHeaders != null) {
this.headerAccessor.setReadOnlyHeaders(readOnlyHeaders);
Expand Down Expand Up @@ -317,7 +316,7 @@ public Message<T> build() {
}

private boolean containsReadOnly(MessageHeaders headers) {
if (!ObjectUtils.isEmpty(this.readOnlyHeaders)) {
if (this.readOnlyHeaders != null) {
for (String readOnly : this.readOnlyHeaders) {
if (headers.containsKey(readOnly)) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
/**
* @author Gary Russell
* @author Artem Bilan
* @author Glenn Renfro
*
* @since 4.0
*
*/
public class DefaultMessageBuilderFactory implements MessageBuilderFactory {

private String[] readOnlyHeaders;
private String @Nullable [] readOnlyHeaders;

/**
* Specify a list of headers which should be considered as a read only
Expand All @@ -41,7 +42,7 @@ public class DefaultMessageBuilderFactory implements MessageBuilderFactory {
* and {@link org.springframework.messaging.MessageHeaders#TIMESTAMP}.
* @since 4.3.2
*/
public void setReadOnlyHeaders(@Nullable String... readOnlyHeaders) {
public void setReadOnlyHeaders(String @Nullable ... readOnlyHeaders) {
this.readOnlyHeaders = readOnlyHeaders != null ? Arrays.copyOf(readOnlyHeaders, readOnlyHeaders.length) : null;
}

Expand All @@ -57,7 +58,7 @@ public void addReadOnlyHeaders(String... readOnlyHeaders) {
}
else {
headers = Arrays.copyOf(headers, headers.length + readOnlyHeaders.length);
System.arraycopy(readOnlyHeaders, 0, headers, this.readOnlyHeaders.length, readOnlyHeaders.length);
System.arraycopy(readOnlyHeaders, 0, headers, (this.readOnlyHeaders != null) ? this.readOnlyHeaders.length : 0, readOnlyHeaders.length);
}
this.readOnlyHeaders = headers;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
*
* @author Gary Russell
* @author Artem Bilan
* @author Glenn Renfro
*
* @since 4.0
*
Expand Down Expand Up @@ -80,9 +81,8 @@ public Map<String, Object> getHeaders() {
}

@SuppressWarnings("unchecked")
@Nullable
@Override
public <V> V getHeader(String key, Class<V> type) {
public @Nullable <V> V getHeader(String key, Class<V> type) {
Object value = this.headers.get(key);
if (value == null) {
return null;
Expand Down Expand Up @@ -218,22 +218,22 @@ public AbstractIntegrationMessageBuilder<T> copyHeadersIfAbsent(@Nullable Map<St

@SuppressWarnings("unchecked")
@Override
protected List<List<Object>> getSequenceDetails() {
protected @Nullable List<List<Object>> getSequenceDetails() {
return (List<List<Object>>) this.headers.get(IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS);
}

@Override
protected Object getCorrelationId() {
protected @Nullable Object getCorrelationId() {
return this.headers.get(IntegrationMessageHeaderAccessor.CORRELATION_ID);
}

@Override
protected Object getSequenceNumber() {
protected @Nullable Object getSequenceNumber() {
return this.headers.get(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER);
}

@Override
protected Object getSequenceSize() {
protected @Nullable Object getSequenceSize() {
return this.headers.get(IntegrationMessageHeaderAccessor.SEQUENCE_SIZE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.springframework.integration.support;

import org.jspecify.annotations.Nullable;

import org.springframework.messaging.converter.MessageConverter;
import org.springframework.messaging.handler.annotation.support.PayloadMethodArgumentResolver;
import org.springframework.validation.Validator;
Expand All @@ -40,7 +42,8 @@ public NullAwarePayloadArgumentResolver(MessageConverter messageConverter, Valid
}

@Override
protected boolean isEmptyPayload(Object payload) {
@SuppressWarnings("NullAway") // Dataflow analysis limitation
protected boolean isEmptyPayload(@Nullable Object payload) {
return super.isEmptyPayload(payload) || "KafkaNull".equals(payload.getClass().getSimpleName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*
* @author Gary Russell
* @author Artem Bilan
* @author Glenn Renfro
*
* @since 4.2
*
Expand Down Expand Up @@ -97,7 +98,9 @@ public <T> Collection<T> getDerivedInput(Class<T> clazz) {

@Override
public String toString() {
return "PartialSuccessException [" + getMessage() + ":" + getCause().getMessage()
Throwable cause = getCause();
String causeMessage = (cause != null) ? cause.getMessage() : "";
return "PartialSuccessException [" + getMessage() + ":" + causeMessage
+ ", partialResults=" + this.partialResults + ", derivedInput=" + this.derivedInput
+ ", failedMessage=" + getFailedMessage() + "]";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
* @author Artem Bilan
* @author Christian Tzolov
* @author Ngoc Nhan
* @author Glenn Renfro
*
* @since 4.2
*
Expand All @@ -73,6 +74,7 @@ public class SmartLifecycleRoleController implements ApplicationListener<Abstrac

private final MultiValueMap<String, String> lazyLifecycles = new LinkedMultiValueMap<>();

@SuppressWarnings("NullAway.Init")
private ApplicationContext applicationContext;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.springframework.integration.support.MessageBuilderFactory;
import org.springframework.integration.support.utils.IntegrationUtils;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;

/**
* Base {@link JsonInboundMessageMapper.JsonMessageParser} implementation for Jackson processors.
Expand All @@ -44,10 +45,12 @@ abstract class AbstractJacksonJsonMessageParser<P> implements JsonInboundMessage

private final JsonObjectMapper<?, P> objectMapper;

@SuppressWarnings("NullAway.Init")
private volatile JsonInboundMessageMapper messageMapper;

private volatile MessageBuilderFactory messageBuilderFactory = new DefaultMessageBuilderFactory();

@SuppressWarnings("NullAway.Init")
private BeanFactory beanFactory;

private volatile boolean messageBuilderFactorySet;
Expand Down Expand Up @@ -82,6 +85,7 @@ public Message<?> doInParser(JsonInboundMessageMapper messageMapperToUse, String

if (messageMapperToUse.isMapToPayload()) {
Object payload = readPayload(parser, jsonMessage);
Assert.state(payload != null, "No payload found in JSON message");
return getMessageBuilderFactory()
.withPayload(payload)
.copyHeaders(headers)
Expand All @@ -92,7 +96,7 @@ public Message<?> doInParser(JsonInboundMessageMapper messageMapperToUse, String
}
}

protected Object readPayload(P parser, String jsonMessage) {
protected @Nullable Object readPayload(P parser, String jsonMessage) {
try {
return this.objectMapper.fromJson(parser, this.messageMapper.getPayloadType());
}
Expand All @@ -102,7 +106,7 @@ protected Object readPayload(P parser, String jsonMessage) {
}
}

protected Object readHeader(P parser, String headerName, String jsonMessage) {
protected @Nullable Object readHeader(P parser, String headerName, String jsonMessage) {
Class<?> headerType = this.messageMapper.getHeaderTypes().getOrDefault(headerName, Object.class);
try {
return this.objectMapper.fromJson(parser, (Type) headerType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.util.Collection;
import java.util.Map;

import org.jspecify.annotations.Nullable;

import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.core.ResolvableType;
import org.springframework.util.ClassUtils;
Expand All @@ -38,6 +40,7 @@
* @param <J> - The expected type of Java Type representation.
*
* @author Artem Bilan
* @author Glenn Renfro
*
* @since 3.0
*/
Expand All @@ -46,14 +49,14 @@ public abstract class AbstractJacksonJsonObjectMapper<N, P, J> implements JsonOb
protected static final Collection<Class<?>> SUPPORTED_JSON_TYPES =
Arrays.asList(String.class, byte[].class, File.class, URL.class, InputStream.class, Reader.class);

private volatile ClassLoader classLoader = ClassUtils.getDefaultClassLoader();
private volatile @Nullable ClassLoader classLoader = ClassUtils.getDefaultClassLoader();

@Override
public void setBeanClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
}

protected ClassLoader getClassLoader() {
protected @Nullable ClassLoader getClassLoader() {
return this.classLoader;
}

Expand Down
Loading