Skip to content

Commit 5722e8d

Browse files
authored
GH-10083: Apply Nullability to FTP module (#10308)
Related to: #10083
1 parent 60314fe commit 5722e8d

24 files changed

+83
-79
lines changed

spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.integration.ftp.config;
1818

19+
import java.util.Objects;
20+
1921
import org.w3c.dom.Element;
2022

2123
import org.springframework.beans.factory.config.BeanDefinition;
@@ -55,7 +57,8 @@ protected void postProcessBuilder(BeanDefinitionBuilder builder, Element element
5557
.iterator()
5658
.next()
5759
.getValue();
58-
templateDefinition.getPropertyValues() // NOSONAR never null
60+
61+
Objects.requireNonNull(templateDefinition).getPropertyValues()
5962
.add("existsMode", FtpRemoteFileTemplate.ExistsMode.NLST);
6063
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "chmod", "chmodOctal");
6164
}

spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundGatewayParser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.integration.ftp.config;
1818

19+
import java.util.Objects;
20+
1921
import org.w3c.dom.Element;
2022

2123
import org.springframework.beans.factory.config.BeanDefinition;
@@ -66,7 +68,8 @@ protected void postProcessBuilder(BeanDefinitionBuilder builder, Element element
6668
.iterator()
6769
.next()
6870
.getValue();
69-
templateDefinition.getPropertyValues() // NOSONAR never null
71+
72+
Objects.requireNonNull(templateDefinition).getPropertyValues()
7073
.add("existsMode", FtpRemoteFileTemplate.ExistsMode.NLST);
7174

7275
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "working-dir-expression",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/**
22
* Provides classes for configuration - parsers, namespace handlers.
33
*/
4+
@org.jspecify.annotations.NullMarked
45
package org.springframework.integration.ftp.config;

spring-integration-ftp/src/main/java/org/springframework/integration/ftp/dsl/Ftp.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Comparator;
2121

2222
import org.apache.commons.net.ftp.FTPFile;
23+
import org.jspecify.annotations.Nullable;
2324

2425
import org.springframework.integration.file.remote.MessageSessionCallback;
2526
import org.springframework.integration.file.remote.RemoteFileTemplate;
@@ -28,7 +29,6 @@
2829
import org.springframework.integration.file.support.FileExistsMode;
2930
import org.springframework.integration.ftp.gateway.FtpOutboundGateway;
3031
import org.springframework.integration.ftp.session.FtpRemoteFileTemplate;
31-
import org.springframework.lang.Nullable;
3232

3333
/**
3434
* The factory for FTP components.
@@ -216,7 +216,7 @@ public static FtpOutboundGatewaySpec outboundGateway(RemoteFileTemplate<FTPFile>
216216
* @see RemoteFileTemplate
217217
*/
218218
public static FtpOutboundGatewaySpec outboundGateway(RemoteFileTemplate<FTPFile> remoteFileTemplate,
219-
AbstractRemoteFileOutboundGateway.Command command, String expression) {
219+
AbstractRemoteFileOutboundGateway.Command command, @Nullable String expression) {
220220

221221
return outboundGateway(remoteFileTemplate, command.getCommand(), expression);
222222
}

spring-integration-ftp/src/main/java/org/springframework/integration/ftp/dsl/FtpInboundChannelAdapterSpec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Comparator;
2121

2222
import org.apache.commons.net.ftp.FTPFile;
23+
import org.jspecify.annotations.Nullable;
2324

2425
import org.springframework.integration.file.dsl.RemoteFileInboundChannelAdapterSpec;
2526
import org.springframework.integration.file.filters.CompositeFileListFilter;
@@ -31,7 +32,6 @@
3132
import org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer;
3233
import org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizingMessageSource;
3334
import org.springframework.integration.metadata.SimpleMetadataStore;
34-
import org.springframework.lang.Nullable;
3535

3636
/**
3737
* A {@link RemoteFileInboundChannelAdapterSpec} for an {@link FtpInboundFileSynchronizingMessageSource}.

spring-integration-ftp/src/main/java/org/springframework/integration/ftp/dsl/FtpStreamingInboundChannelAdapterSpec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.Comparator;
2020

2121
import org.apache.commons.net.ftp.FTPFile;
22+
import org.jspecify.annotations.Nullable;
2223

2324
import org.springframework.integration.file.dsl.RemoteFileStreamingInboundChannelAdapterSpec;
2425
import org.springframework.integration.file.filters.CompositeFileListFilter;
@@ -29,7 +30,6 @@
2930
import org.springframework.integration.ftp.filters.FtpSimplePatternFileListFilter;
3031
import org.springframework.integration.ftp.inbound.FtpStreamingMessageSource;
3132
import org.springframework.integration.metadata.SimpleMetadataStore;
32-
import org.springframework.lang.Nullable;
3333

3434
/**
3535
* A {@link RemoteFileStreamingInboundChannelAdapterSpec} for a {@link FtpStreamingMessageSource}.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* Provides FTP Components for the Java DSL.
33
*/
4-
@org.springframework.lang.NonNullApi
5-
@org.springframework.lang.NonNullFields
4+
@org.jspecify.annotations.NullMarked
65
package org.springframework.integration.ftp.dsl;

spring-integration-ftp/src/main/java/org/springframework/integration/ftp/filters/FtpRegexPatternFileListFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public FtpRegexPatternFileListFilter(Pattern pattern) {
4141

4242
@Override
4343
protected String getFilename(FTPFile file) {
44-
return (file != null) ? file.getName() : null;
44+
return file.getName();
4545
}
4646

4747
@Override

spring-integration-ftp/src/main/java/org/springframework/integration/ftp/filters/FtpSimplePatternFileListFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public FtpSimplePatternFileListFilter(String pattern) {
3535

3636
@Override
3737
protected String getFilename(FTPFile file) {
38-
return (file != null) ? file.getName() : null;
38+
return file.getName();
3939
}
4040

4141
@Override
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/**
22
* Provides classes supporting FTP file filtering.
33
*/
4+
@org.jspecify.annotations.NullMarked
45
package org.springframework.integration.ftp.filters;

0 commit comments

Comments
 (0)