Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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 @@ -142,9 +142,8 @@ public void setComponentName(String componentName) {
* Subclasses may implement this method to provide component type information.
*/
@Override
@Nullable
public String getComponentType() {
return null;
return "integration-object-support";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very good.
I believe we are in a situation where we should remove this method implementation here in the IntegrationObjectSupport.
And ensure that it is implemented properly everywhere else.

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
Expand Down Expand Up @@ -52,9 +53,10 @@ public class BeanFactoryChannelResolver implements DestinationResolver<MessageCh

private final Lock lock = new ReentrantLock();

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

private HeaderChannelRegistry replyChannelRegistry;
private @Nullable HeaderChannelRegistry replyChannelRegistry;

private volatile boolean initialized;

Expand Down Expand Up @@ -89,7 +91,6 @@ public void setBeanFactory(BeanFactory beanFactory) {

@Override
public MessageChannel resolveDestination(String name) {
Assert.state(this.beanFactory != null, "BeanFactory is required");
try {
return this.beanFactory.getBean(name, MessageChannel.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.springframework.integration.support.channel;

import org.jspecify.annotations.Nullable;

import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.messaging.MessageChannel;
Expand All @@ -37,7 +39,7 @@ public interface HeaderChannelRegistry {
* @param channel The channel.
* @return The channel name, or the channel if it is not a MessageChannel.
*/
Object channelToChannelName(Object channel);
@Nullable Object channelToChannelName(Object channel);

/**
* Converts the channel to a name (String). If the channel is not a
Expand All @@ -48,15 +50,15 @@ public interface HeaderChannelRegistry {
* @return The channel name, or the channel if it is not a MessageChannel.
* @since 4.1
*/
Object channelToChannelName(Object channel, long timeToLive);
@Nullable Object channelToChannelName(Object channel, long timeToLive);

/**
* Converts the channel name back to a {@link MessageChannel} (if it is
* registered).
* @param name The name of the channel.
* @return The channel, or null if there is no channel registered with the name.
*/
MessageChannel channelNameToChannel(String name);
@Nullable MessageChannel channelNameToChannel(String name);

/**
* @return the current size of the registry
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* Provides classes supporting use of the channel.
*/
@org.jspecify.annotations.NullMarked
package org.springframework.integration.support.channel;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
* Provides classes supporting use of the application context.
*/
@org.jspecify.annotations.NullMarked
package org.springframework.integration.support.context;
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public class AllowListDeserializingConverter implements Converter<byte[], Object

private final Deserializer<Object> deserializer;

@Nullable
private final ClassLoader defaultDeserializerClassLoader;
private final @Nullable ClassLoader defaultDeserializerClassLoader;

private final boolean usingDefaultDeserializer;

Expand Down Expand Up @@ -136,15 +135,14 @@ public Object convert(byte[] source) {
if (this.usingDefaultDeserializer) {
return deserialize(byteStream);
}
else {
Object result = this.deserializer.deserialize(byteStream);
/* Even if there is no knowledge what is the target deserialization algorithm
and malicious code may be executed already, it is still better to fail
with untrusted data rather than just let it pass downstream.
*/
checkAllowList(result.getClass());
return result;
}

Object result = this.deserializer.deserialize(byteStream);
/* Even if there is no knowledge what is the target deserialization algorithm
and malicious code may be executed already, it is still better to fail
with untrusted data rather than just let it pass downstream.
*/
checkAllowList(result.getClass());
return result;
}
catch (Exception ex) {
throw new SerializationFailedException("Failed to deserialize payload. " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,11 @@ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
* @return the converted payload or null if conversion is not possible.
*/
@Override
public Object fromMessage(Message<?> message, Class<?> targetClass) {
public @Nullable Object fromMessage(Message<?> message, Class<?> targetClass) {
if (this.conversionService.canConvert(message.getPayload().getClass(), targetClass)) {
return this.conversionService.convert(message.getPayload(), targetClass);
}
else {
return null;
}
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class MapMessageConverter implements MessageConverter, BeanFactoryAware {

private boolean filterHeadersInToMessage;

private BeanFactory beanFactory;
private @Nullable BeanFactory beanFactory;

private MessageBuilderFactory messageBuilderFactory = new DefaultMessageBuilderFactory();

Expand Down Expand Up @@ -97,7 +97,6 @@ public void setFilterHeadersInToMessage(boolean filterHeadersInToMessage) {
this.filterHeadersInToMessage = filterHeadersInToMessage;
}

@Nullable
@Override
public Message<?> toMessage(Object object, @Nullable MessageHeaders messageHeaders) {
Assert.isInstanceOf(Map.class, object, "This converter expects a Map");
Expand All @@ -119,7 +118,6 @@ public Message<?> toMessage(Object object, @Nullable MessageHeaders messageHeade
.build();
}

@Nullable
@Override
public Object fromMessage(Message<?> message, Class<?> clazz) {
Map<String, Object> map = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ protected Object convertFromInternal(Message<?> message, Class<?> targetClass, @
if (payload instanceof String || payload instanceof byte[]) {
return super.convertFromInternal(message, targetClass, conversionHint);
}
else {
return payload.toString();
}
return payload.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ public Object fromMessage(Message<?> message, Class<?> targetClass) {
}

@Override
public Message<?> toMessage(Object payload, @Nullable MessageHeaders headers) {
public @Nullable Message<?> toMessage(Object payload, @Nullable MessageHeaders headers) {
if (payload instanceof byte[]) {
return MessageBuilder.withPayload(payload).copyHeaders(headers).build();
}
else {
return null;
}

return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class SimpleMessageConverter implements MessageConverter, BeanFactoryAwar

private boolean messageBuilderFactorySet;

private BeanFactory beanFactory;
private @Nullable BeanFactory beanFactory;

public SimpleMessageConverter() {
}
Expand Down Expand Up @@ -104,9 +104,8 @@ protected MessageBuilderFactory getMessageBuilderFactory() {
return this.messageBuilderFactory;
}

@Nullable
@Override
public Message<?> toMessage(Object object, @Nullable MessageHeaders headers) {
public @Nullable Message<?> toMessage(Object object, @Nullable MessageHeaders headers) {
try {
return this.inboundMessageMapper.toMessage(object, headers);
}
Expand All @@ -115,9 +114,8 @@ public Message<?> toMessage(Object object, @Nullable MessageHeaders headers) {
}
}

@Nullable
@Override
public Object fromMessage(Message<?> message, Class<?> targetClass) {
public @Nullable Object fromMessage(Message<?> message, Class<?> targetClass) {
try {
return this.outboundMessageMapper.fromMessage(message);
}
Expand All @@ -132,7 +130,7 @@ private class DefaultInboundMessageMapper implements InboundMessageMapper<Object
}

@Override
public Message<?> toMessage(@Nullable Object object, @Nullable Map<String, Object> headers) {
public @Nullable Message<?> toMessage(@Nullable Object object, @Nullable Map<String, Object> headers) {
if (object == null) {
return null;
}
Expand All @@ -153,8 +151,8 @@ private static class DefaultOutboundMessageMapper implements OutboundMessageMapp
}

@Override
public Object fromMessage(@Nullable Message<?> message) {
return (message != null) ? message.getPayload() : null;
public Object fromMessage(Message<?> message) {
return message.getPayload();
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* Provides classes supporting message conversion.
*/
@org.springframework.lang.NonNullApi
@org.springframework.lang.NonNullFields
@org.jspecify.annotations.NullMarked
package org.springframework.integration.support.converter;
Loading