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 @@ -211,8 +211,7 @@ public void setChannelResolver(DestinationResolver<MessageChannel> channelResolv
}

@Override
@Nullable
public Expression getExpression() {
public @Nullable Expression getExpression() {
return this.expression;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.jspecify.annotations.Nullable;

import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.integration.endpoint.MessageProducerSupport;
Expand All @@ -41,6 +43,7 @@ public abstract class AbstractInternetProtocolReceivingChannelAdapter

private final int port;

@SuppressWarnings("NullAway.Init")
private ApplicationEventPublisher applicationEventPublisher;

private int soTimeout = 0;
Expand All @@ -49,9 +52,9 @@ public abstract class AbstractInternetProtocolReceivingChannelAdapter

private int receiveBufferSize = 2048; // NOSONAR magic number

private String localAddress;
private @Nullable String localAddress;

private Executor taskExecutor;
private @Nullable Executor taskExecutor;

private boolean taskExecutorSet;

Expand Down Expand Up @@ -117,7 +120,7 @@ public void setListening(boolean listening) {
this.listening = listening;
}

public String getLocalAddress() {
public @Nullable String getLocalAddress() {
return this.localAddress;
}

Expand All @@ -139,7 +142,7 @@ public void setTaskExecutor(Executor taskExecutor) {
/**
* @return the taskExecutor
*/
public Executor getTaskExecutor() {
public @Nullable Executor getTaskExecutor() {
return this.taskExecutor;
}

Expand All @@ -153,6 +156,7 @@ public void setApplicationEventPublisher(ApplicationEventPublisher applicationEv
}

@Override
@SuppressWarnings("NullAway") // Dataflow analysis limitation
protected void doStart() {
String beanName = getComponentName();
checkTaskExecutor((beanName == null ? "" : beanName + "-") + getComponentType());
Expand All @@ -179,8 +183,9 @@ protected void checkTaskExecutor(final String threadName) {

@Override
protected void doStop() {
if (!this.taskExecutorSet && this.taskExecutor != null) {
((ExecutorService) this.taskExecutor).shutdown();
Executor taskExecutorToShutdown = this.taskExecutor;
if (!this.taskExecutorSet && taskExecutorToShutdown != null) {
((ExecutorService) taskExecutorToShutdown).shutdown();
this.taskExecutor = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import java.util.concurrent.Executor;

import org.jspecify.annotations.Nullable;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanNameAware;
Expand Down Expand Up @@ -62,11 +64,12 @@
public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<AbstractConnectionFactory>
implements Lifecycle, BeanNameAware, ApplicationEventPublisherAware, ApplicationContextAware {

@SuppressWarnings("NullAway.Init")
private AbstractConnectionFactory connectionFactory;

private String type;
private @Nullable String type;

private String host;
private @Nullable String host;

private int port;

Expand All @@ -84,7 +87,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac

private int soTrafficClass = -1; // don't set by default

private Executor taskExecutor;
private @Nullable Executor taskExecutor;

private Deserializer<?> deserializer = new ByteArrayCrLfSerializer();

Expand All @@ -98,38 +101,41 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac

private int backlog = 5; // NOSONAR magic number

private TcpConnectionInterceptorFactoryChain interceptorFactoryChain;
private @Nullable TcpConnectionInterceptorFactoryChain interceptorFactoryChain;

private boolean lookupHost = true;

private String localAddress;
private @Nullable String localAddress;

private boolean usingNio;

private boolean usingDirectBuffers;

@SuppressWarnings("NullAway.Init")
private String beanName;

private boolean applySequence;

private Long readDelay;
private @Nullable Long readDelay;

private TcpSSLContextSupport sslContextSupport;
private @Nullable TcpSSLContextSupport sslContextSupport;

private Integer sslHandshakeTimeout;
private @Nullable Integer sslHandshakeTimeout;

private TcpSocketSupport socketSupport = new DefaultTcpSocketSupport();

private TcpNioConnectionSupport nioConnectionSupport;
private @Nullable TcpNioConnectionSupport nioConnectionSupport;

private TcpNetConnectionSupport netConnectionSupport;
private @Nullable TcpNetConnectionSupport netConnectionSupport;

private TcpSocketFactorySupport socketFactorySupport;
private @Nullable TcpSocketFactorySupport socketFactorySupport;

@SuppressWarnings("NullAway.Init")
private ApplicationEventPublisher applicationEventPublisher;

private Integer connectTimeout;
private @Nullable Integer connectTimeout;

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

public TcpConnectionFactoryFactoryBean() {
Expand Down Expand Up @@ -169,6 +175,7 @@ protected AbstractConnectionFactory createInstance() {
this.connectionFactory = factory;
}
else {
Assert.notNull(this.host, "The 'host' must be provided for client factory.");
TcpNioClientConnectionFactory factory = new TcpNioClientConnectionFactory(this.host, this.port);
this.setCommonAttributes(factory);
factory.setUsingDirectBuffers(this.usingDirectBuffers);
Expand All @@ -189,8 +196,8 @@ protected AbstractConnectionFactory createInstance() {
this.connectionFactory = factory;
}
else {
TcpNetClientConnectionFactory factory = new TcpNetClientConnectionFactory(
this.host, this.port);
Assert.notNull(this.host, "The 'host' must be provided for client factory.");
TcpNetClientConnectionFactory factory = new TcpNetClientConnectionFactory(this.host, this.port);
this.setCommonAttributes(factory);
factory.setTcpSocketFactorySupport(this.obtainSocketFactorySupport());
factory.setTcpNetConnectionSupport(this.obtainNetConnectionSupport());
Expand All @@ -203,16 +210,16 @@ protected AbstractConnectionFactory createInstance() {
if (beanFactory != null) {
this.connectionFactory.setBeanFactory(beanFactory);
}
if (this.applicationContext != null) {
this.connectionFactory.setApplicationContext(this.applicationContext);
}
this.connectionFactory.setApplicationContext(this.applicationContext);
this.connectionFactory.afterPropertiesSet();
return this.connectionFactory;
}

private void setCommonAttributes(AbstractConnectionFactory factory) {
factory.setDeserializer(this.deserializer);
factory.setInterceptorFactoryChain(this.interceptorFactoryChain);
if (this.interceptorFactoryChain != null) {
factory.setInterceptorFactoryChain(this.interceptorFactoryChain);
}
factory.setLookupHost(this.lookupHost);
this.mapper.setApplySequence(this.applySequence);
factory.setMapper(this.mapper);
Expand All @@ -225,7 +232,9 @@ private void setCommonAttributes(AbstractConnectionFactory factory) {
factory.setSoTcpNoDelay(this.soTcpNoDelay);
factory.setSoTimeout(this.soTimeout);
factory.setSoTrafficClass(this.soTrafficClass);
factory.setTaskExecutor(this.taskExecutor);
if (this.taskExecutor != null) {
factory.setTaskExecutor(this.taskExecutor);
}
factory.setBeanName(this.beanName);
factory.setTcpSocketSupport(this.socketSupport);
factory.setApplicationEventPublisher(this.applicationEventPublisher);
Expand All @@ -235,7 +244,9 @@ private void setCommonAttributes(AbstractConnectionFactory factory) {
}

private void setServerAttributes(AbstractServerConnectionFactory factory) {
factory.setLocalAddress(this.localAddress);
if (this.localAddress != null) {
factory.setLocalAddress(this.localAddress);
}
factory.setBacklog(this.backlog);
}

Expand Down Expand Up @@ -264,12 +275,7 @@ private TcpNioConnectionSupport obtainNioConnectionSupport() {
}

private TcpNetConnectionSupport obtainNetConnectionSupport() {
if (this.netConnectionSupport != null) {
return this.netConnectionSupport;
}
else {
return new DefaultTcpNetConnectionSupport();
}
return this.netConnectionSupport != null ? this.netConnectionSupport : new DefaultTcpNetConnectionSupport();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
* Provides classes for configuration - parsers, namespace handlers, factory beans.
*/
@org.jspecify.annotations.NullMarked
package org.springframework.integration.ip.config;
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.util.Collections;
import java.util.Map;

import org.jspecify.annotations.Nullable;

import org.springframework.integration.dsl.ComponentsRegistration;
import org.springframework.integration.dsl.MessageProducerSpec;
import org.springframework.integration.ip.tcp.TcpReceivingChannelAdapter;
Expand All @@ -38,7 +40,7 @@ public class TcpInboundChannelAdapterSpec
extends MessageProducerSpec<TcpInboundChannelAdapterSpec, TcpReceivingChannelAdapter>
implements ComponentsRegistration {

protected final AbstractConnectionFactory connectionFactory; // NOSONAR - final
protected final @Nullable AbstractConnectionFactory connectionFactory; // NOSONAR - final

/**
* Construct an instance using an existing spring-managed connection factory.
Expand Down Expand Up @@ -91,10 +93,10 @@ public TcpInboundChannelAdapterSpec taskScheduler(TaskScheduler taskScheduler) {
}

@Override
public Map<Object, String> getComponentsToRegister() {
public Map<Object, @Nullable String> getComponentsToRegister() {
return this.connectionFactory != null
? Collections.singletonMap(this.connectionFactory, this.connectionFactory.getComponentName())
: Collections.emptyMap();
? Collections.<Object, @Nullable String>singletonMap(this.connectionFactory, this.connectionFactory.getComponentName())
: Collections.<Object, @Nullable String>emptyMap();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.util.Collections;
import java.util.Map;

import org.jspecify.annotations.Nullable;

import org.springframework.integration.dsl.ComponentsRegistration;
import org.springframework.integration.dsl.MessagingGatewaySpec;
import org.springframework.integration.ip.tcp.TcpInboundGateway;
Expand All @@ -37,7 +39,7 @@
public class TcpInboundGatewaySpec extends MessagingGatewaySpec<TcpInboundGatewaySpec, TcpInboundGateway>
implements ComponentsRegistration {

protected final AbstractConnectionFactory connectionFactory; // NOSONAR - final
protected final @Nullable AbstractConnectionFactory connectionFactory; // NOSONAR - final

/**
* Construct an instance using an existing spring-managed connection factory.
Expand Down Expand Up @@ -90,10 +92,10 @@ public TcpInboundGatewaySpec taskScheduler(TaskScheduler taskScheduler) {
}

@Override
public Map<Object, String> getComponentsToRegister() {
public Map<Object, @Nullable String> getComponentsToRegister() {
return this.connectionFactory != null
? Collections.singletonMap(this.connectionFactory, this.connectionFactory.getComponentName())
: Collections.emptyMap();
? Collections.<Object, @Nullable String>singletonMap(this.connectionFactory, this.connectionFactory.getComponentName())
: Collections.<Object, @Nullable String>emptyMap();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.util.Collections;
import java.util.Map;

import org.jspecify.annotations.Nullable;

import org.springframework.integration.dsl.ComponentsRegistration;
import org.springframework.integration.dsl.MessageHandlerSpec;
import org.springframework.integration.ip.tcp.TcpSendingMessageHandler;
Expand All @@ -38,7 +40,7 @@ public class TcpOutboundChannelAdapterSpec
extends MessageHandlerSpec<TcpOutboundChannelAdapterSpec, TcpSendingMessageHandler>
implements ComponentsRegistration {

protected final AbstractConnectionFactory connectionFactory; // NOSONAR - final
protected final @Nullable AbstractConnectionFactory connectionFactory; // NOSONAR - final

/**
* Construct an instance using an existing spring-managed connection factory.
Expand Down Expand Up @@ -91,10 +93,10 @@ public TcpOutboundChannelAdapterSpec taskScheduler(TaskScheduler taskScheduler)
}

@Override
public Map<Object, String> getComponentsToRegister() {
public Map<Object, @Nullable String> getComponentsToRegister() {
return this.connectionFactory != null
? Collections.singletonMap(this.connectionFactory, this.connectionFactory.getComponentName())
: Collections.emptyMap();
? Collections.<Object, @Nullable String>singletonMap(this.connectionFactory, this.connectionFactory.getComponentName())
: Collections.<Object, @Nullable String>emptyMap();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.util.Map;
import java.util.function.Function;

import org.jspecify.annotations.Nullable;

import org.springframework.integration.dsl.ComponentsRegistration;
import org.springframework.integration.dsl.MessageHandlerSpec;
import org.springframework.integration.expression.FunctionExpression;
Expand All @@ -40,7 +42,7 @@
public class TcpOutboundGatewaySpec extends MessageHandlerSpec<TcpOutboundGatewaySpec, TcpOutboundGateway>
implements ComponentsRegistration {

protected final AbstractClientConnectionFactory connectionFactory; // NOSONAR - final
protected final @Nullable AbstractClientConnectionFactory connectionFactory; // NOSONAR - final

/**
* Construct an instance using an existing spring-managed connection factory.
Expand Down Expand Up @@ -138,10 +140,10 @@ public TcpOutboundGatewaySpec unsolicitedMessageChannel(MessageChannel channel)
}

@Override
public Map<Object, String> getComponentsToRegister() {
public Map<Object, @Nullable String> getComponentsToRegister() {
return this.connectionFactory != null
? Collections.singletonMap(this.connectionFactory, this.connectionFactory.getComponentName())
: Collections.emptyMap();
? Collections.<Object, @Nullable String>singletonMap(this.connectionFactory, this.connectionFactory.getComponentName())
: Collections.<Object, @Nullable String>emptyMap();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Provides TCP/UDP Component support for the Java DSL.
*/
@org.springframework.lang.NonNullApi
@org.jspecify.annotations.NullMarked
package org.springframework.integration.ip.dsl;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
* ApplicationEvents generated by the ip module.
*/
@org.jspecify.annotations.NullMarked
package org.springframework.integration.ip.event;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
* Base package for IP (TCP/UDP) Support.
*/
@org.jspecify.annotations.NullMarked
package org.springframework.integration.ip;
Loading