Add nullability annotations to smoke-test/spring-boot-smoke-test-parent-context
See gh-46587
This commit is contained in:
parent
45a039e314
commit
7616ed52ee
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package smoketest.parent;
|
package smoketest.parent;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
|
@ -29,6 +30,7 @@ import org.springframework.integration.dsl.Pollers;
|
||||||
import org.springframework.integration.dsl.SourcePollingChannelAdapterSpec;
|
import org.springframework.integration.dsl.SourcePollingChannelAdapterSpec;
|
||||||
import org.springframework.integration.file.FileReadingMessageSource;
|
import org.springframework.integration.file.FileReadingMessageSource;
|
||||||
import org.springframework.integration.file.FileWritingMessageHandler;
|
import org.springframework.integration.file.FileWritingMessageHandler;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class SampleParentContextApplication {
|
public class SampleParentContextApplication {
|
||||||
|
@ -50,7 +52,9 @@ public class SampleParentContextApplication {
|
||||||
@Bean
|
@Bean
|
||||||
public FileReadingMessageSource fileReader() {
|
public FileReadingMessageSource fileReader() {
|
||||||
FileReadingMessageSource reader = new FileReadingMessageSource();
|
FileReadingMessageSource reader = new FileReadingMessageSource();
|
||||||
reader.setDirectory(this.serviceProperties.getInputDir());
|
File inputDir = this.serviceProperties.getInputDir();
|
||||||
|
Assert.state(inputDir != null, "'inputDir' must not be null");
|
||||||
|
reader.setDirectory(inputDir);
|
||||||
return reader;
|
return reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +70,9 @@ public class SampleParentContextApplication {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public FileWritingMessageHandler fileWriter() {
|
public FileWritingMessageHandler fileWriter() {
|
||||||
FileWritingMessageHandler writer = new FileWritingMessageHandler(this.serviceProperties.getOutputDir());
|
File outputDir = this.serviceProperties.getOutputDir();
|
||||||
|
Assert.state(outputDir != null, "'outputDir' must not be null");
|
||||||
|
FileWritingMessageHandler writer = new FileWritingMessageHandler(outputDir);
|
||||||
writer.setExpectReply(false);
|
writer.setExpectReply(false);
|
||||||
return writer;
|
return writer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ package smoketest.parent;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.jmx.export.annotation.ManagedAttribute;
|
import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||||
import org.springframework.jmx.export.annotation.ManagedResource;
|
import org.springframework.jmx.export.annotation.ManagedResource;
|
||||||
|
@ -28,9 +30,9 @@ public class ServiceProperties {
|
||||||
|
|
||||||
private String greeting = "Hello";
|
private String greeting = "Hello";
|
||||||
|
|
||||||
private File inputDir;
|
private @Nullable File inputDir;
|
||||||
|
|
||||||
private File outputDir;
|
private @Nullable File outputDir;
|
||||||
|
|
||||||
@ManagedAttribute
|
@ManagedAttribute
|
||||||
public String getGreeting() {
|
public String getGreeting() {
|
||||||
|
@ -41,19 +43,19 @@ public class ServiceProperties {
|
||||||
this.greeting = greeting;
|
this.greeting = greeting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getInputDir() {
|
public @Nullable File getInputDir() {
|
||||||
return this.inputDir;
|
return this.inputDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInputDir(File inputDir) {
|
public void setInputDir(@Nullable File inputDir) {
|
||||||
this.inputDir = inputDir;
|
this.inputDir = inputDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getOutputDir() {
|
public @Nullable File getOutputDir() {
|
||||||
return this.outputDir;
|
return this.outputDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOutputDir(File outputDir) {
|
public void setOutputDir(@Nullable File outputDir) {
|
||||||
this.outputDir = outputDir;
|
this.outputDir = outputDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-present the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@NullMarked
|
||||||
|
package smoketest.parent;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.NullMarked;
|
Loading…
Reference in New Issue