Make fields final
Closes gh-33537
This commit is contained in:
@@ -45,7 +45,7 @@ public abstract class AbstractRabbitListenerContainerFactoryConfigurer<T extends
|
||||
|
||||
private List<RabbitRetryTemplateCustomizer> retryTemplateCustomizers;
|
||||
|
||||
private RabbitProperties rabbitProperties;
|
||||
private final RabbitProperties rabbitProperties;
|
||||
|
||||
/**
|
||||
* Creates a new configurer that will use the given {@code rabbitProperties}.
|
||||
|
||||
@@ -37,7 +37,7 @@ public class RabbitTemplateConfigurer {
|
||||
|
||||
private List<RabbitRetryTemplateCustomizer> retryTemplateCustomizers;
|
||||
|
||||
private RabbitProperties rabbitProperties;
|
||||
private final RabbitProperties rabbitProperties;
|
||||
|
||||
/**
|
||||
* Creates a new configurer that will use the given {@code rabbitProperties}.
|
||||
|
||||
@@ -81,7 +81,7 @@ class OnJndiCondition extends SpringBootCondition {
|
||||
|
||||
protected static class JndiLocator extends JndiLocatorSupport {
|
||||
|
||||
private String[] locations;
|
||||
private final String[] locations;
|
||||
|
||||
public JndiLocator(String[] locations) {
|
||||
this.locations = locations;
|
||||
|
||||
@@ -87,7 +87,7 @@ public class MessageSourceAutoConfiguration {
|
||||
|
||||
protected static class ResourceBundleCondition extends SpringBootCondition {
|
||||
|
||||
private static ConcurrentReferenceHashMap<String, ConditionOutcome> cache = new ConcurrentReferenceHashMap<>();
|
||||
private static final ConcurrentReferenceHashMap<String, ConditionOutcome> cache = new ConcurrentReferenceHashMap<>();
|
||||
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
|
||||
|
||||
@@ -89,7 +89,7 @@ public class GraphQlWebMvcAutoConfiguration {
|
||||
private static final Log logger = LogFactory.getLog(GraphQlWebMvcAutoConfiguration.class);
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static MediaType[] SUPPORTED_MEDIA_TYPES = new MediaType[] { MediaType.APPLICATION_GRAPHQL_RESPONSE,
|
||||
private static final MediaType[] SUPPORTED_MEDIA_TYPES = new MediaType[] { MediaType.APPLICATION_GRAPHQL_RESPONSE,
|
||||
MediaType.APPLICATION_JSON, MediaType.APPLICATION_GRAPHQL };
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -58,7 +58,7 @@ public class EmbeddedLdapProperties {
|
||||
/**
|
||||
* Schema validation.
|
||||
*/
|
||||
private Validation validation = new Validation();
|
||||
private final Validation validation = new Validation();
|
||||
|
||||
public int getPort() {
|
||||
return this.port;
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class ConditionEvaluationReportMessage {
|
||||
|
||||
private StringBuilder message;
|
||||
private final StringBuilder message;
|
||||
|
||||
public ConditionEvaluationReportMessage(ConditionEvaluationReport report) {
|
||||
this(report, "CONDITIONS EVALUATION REPORT");
|
||||
|
||||
@@ -69,7 +69,7 @@ public class MailProperties {
|
||||
/**
|
||||
* Additional JavaMail Session properties.
|
||||
*/
|
||||
private Map<String, String> properties = new HashMap<>();
|
||||
private final Map<String, String> properties = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Session JNDI name. When set, takes precedence over other Session settings.
|
||||
|
||||
@@ -80,7 +80,7 @@ class HibernateJpaConfiguration extends JpaBaseConfiguration {
|
||||
|
||||
private final HibernateDefaultDdlAutoProvider defaultDdlAutoProvider;
|
||||
|
||||
private DataSourcePoolMetadataProvider poolMetadataProvider;
|
||||
private final DataSourcePoolMetadataProvider poolMetadataProvider;
|
||||
|
||||
private final List<HibernatePropertiesCustomizer> hibernatePropertiesCustomizers;
|
||||
|
||||
|
||||
@@ -1787,12 +1787,12 @@ public class ServerProperties {
|
||||
/**
|
||||
* Socket options as defined in org.xnio.Options.
|
||||
*/
|
||||
private Map<String, String> socket = new LinkedHashMap<>();
|
||||
private final Map<String, String> socket = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* Server options as defined in io.undertow.UndertowOptions.
|
||||
*/
|
||||
private Map<String, String> server = new LinkedHashMap<>();
|
||||
private final Map<String, String> server = new LinkedHashMap<>();
|
||||
|
||||
public Map<String, String> getServer() {
|
||||
return this.server;
|
||||
|
||||
@@ -66,7 +66,7 @@ public class DefaultErrorViewResolver implements ErrorViewResolver, Ordered {
|
||||
SERIES_VIEWS = Collections.unmodifiableMap(views);
|
||||
}
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
private final Resources resources;
|
||||
|
||||
@@ -145,7 +145,7 @@ public class DefaultErrorViewResolver implements ErrorViewResolver, Ordered {
|
||||
*/
|
||||
private static class HtmlResourceView implements View {
|
||||
|
||||
private Resource resource;
|
||||
private final Resource resource;
|
||||
|
||||
HtmlResourceView(Resource resource) {
|
||||
this.resource = resource;
|
||||
|
||||
@@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
class AbstractDependsOnBeanFactoryPostProcessorTests {
|
||||
|
||||
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(FooBarConfiguration.class);
|
||||
|
||||
@Test
|
||||
|
||||
@@ -56,7 +56,7 @@ class AutoConfigurationImportSelectorTests {
|
||||
|
||||
private final MockEnvironment environment = new MockEnvironment();
|
||||
|
||||
private List<AutoConfigurationImportFilter> filters = new ArrayList<>();
|
||||
private final List<AutoConfigurationImportFilter> filters = new ArrayList<>();
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
|
||||
@@ -488,7 +488,7 @@ class ConditionalOnBeanTests {
|
||||
@TestAnnotation
|
||||
static class ExampleBean {
|
||||
|
||||
private String value;
|
||||
private final String value;
|
||||
|
||||
ExampleBean(String value) {
|
||||
this.value = value;
|
||||
|
||||
@@ -51,7 +51,7 @@ class ConditionalOnJndiTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();
|
||||
|
||||
private MockableOnJndi condition = new MockableOnJndi();
|
||||
private final MockableOnJndi condition = new MockableOnJndi();
|
||||
|
||||
@BeforeEach
|
||||
void setupThreadContextClassLoader() {
|
||||
@@ -149,7 +149,7 @@ class ConditionalOnJndiTests {
|
||||
|
||||
static class MockableOnJndi extends OnJndiCondition {
|
||||
|
||||
private boolean jndiAvailable = true;
|
||||
private final boolean jndiAvailable = true;
|
||||
|
||||
private String foundLocation;
|
||||
|
||||
|
||||
@@ -741,7 +741,7 @@ class ConditionalOnMissingBeanTests {
|
||||
@TestAnnotation
|
||||
static class ExampleBean {
|
||||
|
||||
private String value;
|
||||
private final String value;
|
||||
|
||||
ExampleBean(String value) {
|
||||
this.value = value;
|
||||
|
||||
@@ -50,7 +50,7 @@ class ConditionalOnPropertyTests {
|
||||
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
private ConfigurableEnvironment environment = new StandardEnvironment();
|
||||
private final ConfigurableEnvironment environment = new StandardEnvironment();
|
||||
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
|
||||
@@ -35,9 +35,9 @@ import static org.mockito.Mockito.mock;
|
||||
*/
|
||||
class OnClassConditionAutoConfigurationImportFilterTests {
|
||||
|
||||
private OnClassCondition filter = new OnClassCondition();
|
||||
private final OnClassCondition filter = new OnClassCondition();
|
||||
|
||||
private DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
|
||||
@@ -32,11 +32,11 @@ public class City implements Serializable {
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
private String state;
|
||||
|
||||
private Country country;
|
||||
private final Country country;
|
||||
|
||||
private String map;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Country implements Serializable {
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
public Country(String name) {
|
||||
this.name = name;
|
||||
|
||||
@@ -50,7 +50,7 @@ class RedisRepositoriesAutoConfigurationTests {
|
||||
public static RedisContainer redis = new RedisContainer().withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
@@ -31,7 +31,8 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public final class GraphQlTestDataFetchers {
|
||||
|
||||
private static List<Book> books = Arrays.asList(new Book("book-1", "GraphQL for beginners", 100, "John GraphQL"),
|
||||
private static final List<Book> books = Arrays.asList(
|
||||
new Book("book-1", "GraphQL for beginners", 100, "John GraphQL"),
|
||||
new Book("book-2", "Harry Potter and the Philosopher's Stone", 223, "Joanne Rowling"),
|
||||
new Book("book-3", "Moby Dick", 635, "Moby Dick"), new Book("book-3", "Moby Dick", 635, "Moby Dick"));
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class GroovyTemplateAutoConfigurationTests {
|
||||
|
||||
private final BuildOutput buildOutput = new BuildOutput(getClass());
|
||||
|
||||
private AnnotationConfigServletWebApplicationContext context = new AnnotationConfigServletWebApplicationContext();
|
||||
private final AnnotationConfigServletWebApplicationContext context = new AnnotationConfigServletWebApplicationContext();
|
||||
|
||||
@BeforeEach
|
||||
void setupContext() {
|
||||
|
||||
@@ -32,11 +32,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
class GroovyTemplateAvailabilityProviderTests {
|
||||
|
||||
private TemplateAvailabilityProvider provider = new GroovyTemplateAvailabilityProvider();
|
||||
private final TemplateAvailabilityProvider provider = new GroovyTemplateAvailabilityProvider();
|
||||
|
||||
private ResourceLoader resourceLoader = new DefaultResourceLoader();
|
||||
private final ResourceLoader resourceLoader = new DefaultResourceLoader();
|
||||
|
||||
private MockEnvironment environment = new MockEnvironment();
|
||||
private final MockEnvironment environment = new MockEnvironment();
|
||||
|
||||
@Test
|
||||
void availabilityOfTemplateInDefaultLocation() {
|
||||
|
||||
@@ -241,7 +241,7 @@ class GsonAutoConfigurationTests {
|
||||
private Long data = 1L;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private String owner = null;
|
||||
private final String owner = null;
|
||||
|
||||
public void setData(Long data) {
|
||||
this.data = data;
|
||||
@@ -254,7 +254,7 @@ class GsonAutoConfigurationTests {
|
||||
@SuppressWarnings("unused")
|
||||
class NestedObject {
|
||||
|
||||
private String data = "nested";
|
||||
private final String data = "nested";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -636,7 +636,7 @@ class JacksonAutoConfigurationTests {
|
||||
|
||||
static class CustomModule extends SimpleModule {
|
||||
|
||||
private Set<ObjectCodec> owners = new HashSet<>();
|
||||
private final Set<ObjectCodec> owners = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public void setupModule(SetupContext context) {
|
||||
|
||||
@@ -80,7 +80,7 @@ class DataSourceJsonSerializationTests {
|
||||
|
||||
static class TomcatDataSourceSerializer extends JsonSerializer<DataSource> {
|
||||
|
||||
private ConversionService conversionService = new DefaultConversionService();
|
||||
private final ConversionService conversionService = new DefaultConversionService();
|
||||
|
||||
@Override
|
||||
public void serialize(DataSource value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
|
||||
@@ -99,7 +99,7 @@ class DataSourceJsonSerializationTests {
|
||||
|
||||
static class GenericSerializerModifier extends BeanSerializerModifier {
|
||||
|
||||
private ConversionService conversionService = new DefaultConversionService();
|
||||
private final ConversionService conversionService = new DefaultConversionService();
|
||||
|
||||
@Override
|
||||
public List<BeanPropertyWriter> changeProperties(SerializationConfig config, BeanDescription beanDesc,
|
||||
|
||||
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
class ParentAwareNamingStrategyTests {
|
||||
|
||||
private ApplicationContextRunner contextRunner = new ApplicationContextRunner();
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();
|
||||
|
||||
@Test
|
||||
void objectNameMatchesManagedResourceByDefault() {
|
||||
|
||||
@@ -462,7 +462,7 @@ class LiquibaseAutoConfigurationTests {
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class CustomDataSourceConfiguration {
|
||||
|
||||
private String name = UUID.randomUUID().toString();
|
||||
private final String name = UUID.randomUUID().toString();
|
||||
|
||||
@Bean(destroyMethod = "shutdown")
|
||||
EmbeddedDatabase dataSource() throws SQLException {
|
||||
@@ -484,7 +484,7 @@ class LiquibaseAutoConfigurationTests {
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class CustomDriverConfiguration {
|
||||
|
||||
private String name = UUID.randomUUID().toString();
|
||||
private final String name = UUID.randomUUID().toString();
|
||||
|
||||
@Bean
|
||||
SimpleDriverDataSource dataSource() {
|
||||
|
||||
@@ -51,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
@ExtendWith(OutputCaptureExtension.class)
|
||||
class ConditionEvaluationReportLoggingListenerTests {
|
||||
|
||||
private ConditionEvaluationReportLoggingListener initializer = new ConditionEvaluationReportLoggingListener();
|
||||
private final ConditionEvaluationReportLoggingListener initializer = new ConditionEvaluationReportLoggingListener();
|
||||
|
||||
@Test
|
||||
void logsDebugOnContextRefresh(CapturedOutput output) {
|
||||
|
||||
@@ -33,11 +33,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
class SecurityPropertiesTests {
|
||||
|
||||
private SecurityProperties security = new SecurityProperties();
|
||||
private final SecurityProperties security = new SecurityProperties();
|
||||
|
||||
private Binder binder;
|
||||
|
||||
private MapConfigurationPropertySource source = new MapConfigurationPropertySource();
|
||||
private final MapConfigurationPropertySource source = new MapConfigurationPropertySource();
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
@@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
*/
|
||||
class OAuth2ClientPropertiesTests {
|
||||
|
||||
private OAuth2ClientProperties properties = new OAuth2ClientProperties();
|
||||
private final OAuth2ClientProperties properties = new OAuth2ClientProperties();
|
||||
|
||||
@Test
|
||||
void clientIdAbsentThrowsException() {
|
||||
|
||||
@@ -79,7 +79,7 @@ import static org.mockito.Mockito.mock;
|
||||
*/
|
||||
class OAuth2ResourceServerAutoConfigurationTests {
|
||||
|
||||
private WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
|
||||
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(OAuth2ResourceServerAutoConfiguration.class))
|
||||
.withUserConfiguration(TestConfig.class);
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ import static org.mockito.Mockito.mock;
|
||||
*/
|
||||
class StaticResourceRequestTests {
|
||||
|
||||
private StaticResourceRequest resourceRequest = StaticResourceRequest.INSTANCE;
|
||||
private final StaticResourceRequest resourceRequest = StaticResourceRequest.INSTANCE;
|
||||
|
||||
@Test
|
||||
void atCommonLocationsShouldMatchCommonLocations() {
|
||||
|
||||
@@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
*/
|
||||
class StaticResourceRequestTests {
|
||||
|
||||
private StaticResourceRequest resourceRequest = StaticResourceRequest.INSTANCE;
|
||||
private final StaticResourceRequest resourceRequest = StaticResourceRequest.INSTANCE;
|
||||
|
||||
@Test
|
||||
void atCommonLocationsShouldMatchCommonLocations() {
|
||||
|
||||
@@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
class SqlInitializationAutoConfigurationTests {
|
||||
|
||||
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(SqlInitializationAutoConfiguration.class)).withPropertyValues(
|
||||
"spring.datasource.generate-unique-name:true", "spring.r2dbc.generate-unique-name:true");
|
||||
|
||||
|
||||
@@ -49,11 +49,11 @@ class TemplateAvailabilityProvidersTests {
|
||||
@Mock
|
||||
private TemplateAvailabilityProvider provider;
|
||||
|
||||
private String view = "view";
|
||||
private final String view = "view";
|
||||
|
||||
private ClassLoader classLoader = getClass().getClassLoader();
|
||||
private final ClassLoader classLoader = getClass().getClassLoader();
|
||||
|
||||
private MockEnvironment environment = new MockEnvironment();
|
||||
private final MockEnvironment environment = new MockEnvironment();
|
||||
|
||||
@Mock
|
||||
private ResourceLoader resourceLoader;
|
||||
|
||||
@@ -422,7 +422,7 @@ class ValidationAutoConfigurationTests {
|
||||
|
||||
static class TestBeanPostProcessor implements BeanPostProcessor {
|
||||
|
||||
private Set<String> postProcessed = new HashSet<>();
|
||||
private final Set<String> postProcessed = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String name) {
|
||||
|
||||
@@ -134,7 +134,7 @@ class ValidatorAdapterTests {
|
||||
static class SampleData {
|
||||
|
||||
@Min(42)
|
||||
private int counter;
|
||||
private final int counter;
|
||||
|
||||
SampleData(int counter) {
|
||||
this.counter = counter;
|
||||
|
||||
@@ -39,7 +39,7 @@ import static org.mockito.Mockito.mock;
|
||||
*/
|
||||
class ReactiveWebServerFactoryCustomizerTests {
|
||||
|
||||
private ServerProperties properties = new ServerProperties();
|
||||
private final ServerProperties properties = new ServerProperties();
|
||||
|
||||
private ReactiveWebServerFactoryCustomizer customizer;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class WelcomePageIntegrationTests {
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
private TestRestTemplate template = new TestRestTemplate();
|
||||
private final TestRestTemplate template = new TestRestTemplate();
|
||||
|
||||
@Test
|
||||
void contentStrategyWithWelcomePage() throws Exception {
|
||||
|
||||
@@ -65,9 +65,9 @@ class DefaultErrorViewResolverTests {
|
||||
|
||||
private Resources resourcesProperties;
|
||||
|
||||
private Map<String, Object> model = new HashMap<>();
|
||||
private final Map<String, Object> model = new HashMap<>();
|
||||
|
||||
private HttpServletRequest request = new MockHttpServletRequest();
|
||||
private final HttpServletRequest request = new MockHttpServletRequest();
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
|
||||
@@ -51,7 +51,7 @@ class RemappedErrorViewIntegrationTests {
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
private TestRestTemplate template = new TestRestTemplate();
|
||||
private final TestRestTemplate template = new TestRestTemplate();
|
||||
|
||||
@Test
|
||||
void directAccessToErrorPage() {
|
||||
|
||||
@@ -78,7 +78,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
||||
*/
|
||||
class WebSocketMessagingAutoConfigurationTests {
|
||||
|
||||
private AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
private final AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
|
||||
private SockJsClient sockJsClient;
|
||||
|
||||
@@ -255,9 +255,9 @@ class WebSocketMessagingAutoConfigurationTests {
|
||||
|
||||
public static class Data {
|
||||
|
||||
private int foo;
|
||||
private final int foo;
|
||||
|
||||
private String bar;
|
||||
private final String bar;
|
||||
|
||||
Data(int foo, String bar) {
|
||||
this.foo = foo;
|
||||
|
||||
Reference in New Issue
Block a user