Make fields final

Closes gh-33537
pull/33545/head
Moritz Halbritter 2 years ago
parent 216d15997a
commit 725337f976

@ -58,7 +58,7 @@ import org.springframework.util.StringUtils;
*/
public class UpgradeBom extends DefaultTask {
private Set<String> repositoryUrls;
private final Set<String> repositoryUrls;
private final BomExtension bom;

@ -35,7 +35,7 @@ import org.gradle.api.tasks.TaskAction;
*/
public class PrepareMavenBinaries extends DefaultTask {
private Set<String> versions = new LinkedHashSet<>();
private final Set<String> versions = new LinkedHashSet<>();
private File outputDir;

@ -42,7 +42,7 @@ public class ConfigurationPropertiesReportEndpointProperties {
* Roles used to determine whether a user is authorized to be shown unsanitized
* values. When empty, all authenticated users are authorized.
*/
private Set<String> roles = new HashSet<>();
private final Set<String> roles = new HashSet<>();
public Show getShowValues() {
return this.showValues;

@ -41,7 +41,7 @@ public class EnvironmentEndpointProperties {
* Roles used to determine whether a user is authorized to be shown unsanitized
* values. When empty, all authenticated users are authorized.
*/
private Set<String> roles = new HashSet<>();
private final Set<String> roles = new HashSet<>();
public Show getShowValues() {
return this.showValues;

@ -41,7 +41,7 @@ public class QuartzEndpointProperties {
* Roles used to determine whether a user is authorized to be shown unsanitized job or
* trigger values. When empty, all authenticated users are authorized.
*/
private Set<String> roles = new HashSet<>();
private final Set<String> roles = new HashSet<>();
public Show getShowValues() {
return this.showValues;

@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
class AvailabilityProbesAutoConfigurationTests {
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(ApplicationAvailabilityAutoConfiguration.class,
AvailabilityHealthContributorAutoConfiguration.class, AvailabilityProbesAutoConfiguration.class));

@ -32,7 +32,8 @@ import static org.mockito.Mockito.mock;
*/
class AvailabilityProbesHealthEndpointGroupTests {
private AvailabilityProbesHealthEndpointGroup group = new AvailabilityProbesHealthEndpointGroup(null, "a", "b");
private final AvailabilityProbesHealthEndpointGroup group = new AvailabilityProbesHealthEndpointGroup(null, "a",
"b");
@Test
void isMemberWhenMemberReturnsTrue() {

@ -37,7 +37,7 @@ import static org.mockito.Mockito.mock;
*/
class AvailabilityProbesHealthEndpointGroupsPostProcessorTests {
private AvailabilityProbesHealthEndpointGroupsPostProcessor postProcessor = new AvailabilityProbesHealthEndpointGroupsPostProcessor(
private final AvailabilityProbesHealthEndpointGroupsPostProcessor postProcessor = new AvailabilityProbesHealthEndpointGroupsPostProcessor(
new MockEnvironment());
@Test

@ -31,7 +31,7 @@ import static org.mockito.Mockito.mock;
*/
class CloudFoundryEndpointFilterTests {
private CloudFoundryEndpointFilter filter = new CloudFoundryEndpointFilter();
private final CloudFoundryEndpointFilter filter = new CloudFoundryEndpointFilter();
@Test
void matchIfDiscovererCloudFoundryShouldReturnFalse() {

@ -71,9 +71,9 @@ import static org.mockito.Mockito.mock;
*/
class CloudFoundryWebFluxEndpointIntegrationTests {
private static ReactiveTokenValidator tokenValidator = mock(ReactiveTokenValidator.class);
private static final ReactiveTokenValidator tokenValidator = mock(ReactiveTokenValidator.class);
private static ReactiveCloudFoundrySecurityService securityService = mock(
private static final ReactiveCloudFoundrySecurityService securityService = mock(
ReactiveCloudFoundrySecurityService.class);
private final ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner(

@ -66,9 +66,9 @@ import static org.mockito.Mockito.mock;
*/
class CloudFoundryMvcWebEndpointIntegrationTests {
private static TokenValidator tokenValidator = mock(TokenValidator.class);
private static final TokenValidator tokenValidator = mock(TokenValidator.class);
private static CloudFoundrySecurityService securityService = mock(CloudFoundrySecurityService.class);
private static final CloudFoundrySecurityService securityService = mock(CloudFoundrySecurityService.class);
@Test
void operationWithSecurityInterceptorForbidden() {

@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
class JacksonEndpointAutoConfigurationTests {
private ApplicationContextRunner runner = new ApplicationContextRunner()
private final ApplicationContextRunner runner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(JacksonEndpointAutoConfiguration.class));
@Test

@ -50,11 +50,11 @@ class MeterRegistryPostProcessorTests {
private final MetricsProperties properties = new MetricsProperties();
private List<MeterRegistryCustomizer<?>> customizers = new ArrayList<>();
private final List<MeterRegistryCustomizer<?>> customizers = new ArrayList<>();
private List<MeterFilter> filters = new ArrayList<>();
private final List<MeterFilter> filters = new ArrayList<>();
private List<MeterBinder> binders = new ArrayList<>();
private final List<MeterBinder> binders = new ArrayList<>();
@Mock
private MeterRegistryCustomizer<MeterRegistry> mockCustomizer;

@ -36,9 +36,10 @@ import static org.mockito.Mockito.mock;
*/
class MetricsRepositoryMethodInvocationListenerBeanPostProcessorTests {
private MetricsRepositoryMethodInvocationListener listener = mock(MetricsRepositoryMethodInvocationListener.class);
private final MetricsRepositoryMethodInvocationListener listener = mock(
MetricsRepositoryMethodInvocationListener.class);
private MetricsRepositoryMethodInvocationListenerBeanPostProcessor postProcessor = new MetricsRepositoryMethodInvocationListenerBeanPostProcessor(
private final MetricsRepositoryMethodInvocationListenerBeanPostProcessor postProcessor = new MetricsRepositoryMethodInvocationListenerBeanPostProcessor(
SingletonSupplier.of(this.listener));
@Test

@ -44,12 +44,12 @@ class ClientHttpObservationConventionAdapterTests {
private static final String TEST_METRIC_NAME = "test.metric.name";
private ClientHttpObservationConventionAdapter convention = new ClientHttpObservationConventionAdapter(
private final ClientHttpObservationConventionAdapter convention = new ClientHttpObservationConventionAdapter(
TEST_METRIC_NAME, new DefaultRestTemplateExchangeTagsProvider());
private ClientHttpRequest request = new MockClientHttpRequest(HttpMethod.GET, URI.create("/resource/test"));
private final ClientHttpRequest request = new MockClientHttpRequest(HttpMethod.GET, URI.create("/resource/test"));
private ClientHttpResponse response = new MockClientHttpResponse("foo".getBytes(), HttpStatus.OK);
private final ClientHttpResponse response = new MockClientHttpResponse("foo".getBytes(), HttpStatus.OK);
private ClientRequestObservationContext context;

@ -43,13 +43,14 @@ class ClientObservationConventionAdapterTests {
private static final String TEST_METRIC_NAME = "test.metric.name";
private ClientObservationConventionAdapter convention = new ClientObservationConventionAdapter(TEST_METRIC_NAME,
new DefaultWebClientExchangeTagsProvider());
private final ClientObservationConventionAdapter convention = new ClientObservationConventionAdapter(
TEST_METRIC_NAME, new DefaultWebClientExchangeTagsProvider());
private ClientRequest.Builder requestBuilder = ClientRequest.create(HttpMethod.GET, URI.create("/resource/test"))
private final ClientRequest.Builder requestBuilder = ClientRequest
.create(HttpMethod.GET, URI.create("/resource/test"))
.attribute(WebClient.class.getName() + ".uriTemplate", "/resource/{name}");
private ClientResponse response = ClientResponse.create(HttpStatus.OK).body("foo").build();
private final ClientResponse response = ClientResponse.create(HttpStatus.OK).body("foo").build();
private ClientRequestObservationContext context;

@ -47,14 +47,15 @@ class ServerRequestObservationConventionAdapterTests {
private static final String TEST_METRIC_NAME = "test.metric.name";
private ServerRequestObservationConventionAdapter convention = new ServerRequestObservationConventionAdapter(
private final ServerRequestObservationConventionAdapter convention = new ServerRequestObservationConventionAdapter(
TEST_METRIC_NAME, new DefaultWebMvcTagsProvider(), Collections.emptyList());
private MockHttpServletRequest request = new MockHttpServletRequest("GET", "/resource/test");
private final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/resource/test");
private MockHttpServletResponse response = new MockHttpServletResponse();
private final MockHttpServletResponse response = new MockHttpServletResponse();
private ServerRequestObservationContext context = new ServerRequestObservationContext(this.request, this.response);
private final ServerRequestObservationContext context = new ServerRequestObservationContext(this.request,
this.response);
@Test
void customNameIsUsed() {

@ -43,9 +43,9 @@ class CompositeHandlerExceptionResolverTests {
private AnnotationConfigApplicationContext context;
private MockHttpServletRequest request = new MockHttpServletRequest();
private final MockHttpServletRequest request = new MockHttpServletRequest();
private MockHttpServletResponse response = new MockHttpServletResponse();
private final MockHttpServletResponse response = new MockHttpServletResponse();
@Test
void resolverShouldDelegateToOtherResolversInContext() {

@ -401,11 +401,11 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
private final EndpointId id;
private boolean enabledByDefault;
private final boolean enabledByDefault;
private final Class<?> filter;
private Set<ExtensionBean> extensions = new LinkedHashSet<>();
private final Set<ExtensionBean> extensions = new LinkedHashSet<>();
EndpointBean(Environment environment, String beanName, Class<?> beanType, Supplier<Object> beanSupplier) {
MergedAnnotation<Endpoint> annotation = MergedAnnotations.from(beanType, SearchStrategy.TYPE_HIERARCHY)

@ -190,7 +190,7 @@ public final class Health extends HealthComponent {
private Status status;
private Map<String, Object> details;
private final Map<String, Object> details;
private Throwable exception;

@ -161,7 +161,7 @@ public class LoggersEndpoint {
*/
public static class LoggerLevelsDescriptor implements OperationResponseBody {
private String configuredLevel;
private final String configuredLevel;
public LoggerLevelsDescriptor(LogLevel configuredLevel) {
this.configuredLevel = getName(configuredLevel);
@ -182,7 +182,7 @@ public class LoggersEndpoint {
*/
public static class GroupLoggerLevelsDescriptor extends LoggerLevelsDescriptor {
private List<String> members;
private final List<String> members;
public GroupLoggerLevelsDescriptor(LogLevel configuredLevel, List<String> members) {
super(configuredLevel);
@ -200,7 +200,7 @@ public class LoggersEndpoint {
*/
public static class SingleLoggerLevelsDescriptor extends LoggerLevelsDescriptor {
private String effectiveLevel;
private final String effectiveLevel;
public SingleLoggerLevelsDescriptor(LoggerConfiguration configuration) {
super(configuration.getConfiguredLevel());

@ -146,9 +146,9 @@ public class HeapDumpWebEndpoint {
*/
protected static class HotSpotDiagnosticMXBeanHeapDumper implements HeapDumper {
private Object diagnosticMXBean;
private final Object diagnosticMXBean;
private Method dumpHeapMethod;
private final Method dumpHeapMethod;
@SuppressWarnings("unchecked")
protected HotSpotDiagnosticMXBeanHeapDumper() {
@ -189,9 +189,9 @@ public class HeapDumpWebEndpoint {
*/
private static final class OpenJ9DiagnosticsMXBeanHeapDumper implements HeapDumper {
private Object diagnosticMXBean;
private final Object diagnosticMXBean;
private Method dumpHeapMethod;
private final Method dumpHeapMethod;
@SuppressWarnings("unchecked")
private OpenJ9DiagnosticsMXBeanHeapDumper() {

@ -56,7 +56,7 @@ public class PrometheusPushGatewayManager {
private final TaskScheduler scheduler;
private ScheduledFuture<?> scheduled;
private final ScheduledFuture<?> scheduled;
/**
* Create a new {@link PrometheusPushGatewayManager} instance using a single threaded

@ -53,7 +53,7 @@ public class AuthenticationAuditListener extends AbstractAuthenticationAuditList
private static final String WEB_LISTENER_CHECK_CLASS = "org.springframework.security.web.authentication.switchuser.AuthenticationSwitchUserEvent";
private WebAuditListener webListener = maybeCreateWebListener();
private final WebAuditListener webListener = maybeCreateWebListener();
private static WebAuditListener maybeCreateWebListener() {
if (ClassUtils.isPresent(WEB_LISTENER_CHECK_CLASS, null)) {

@ -497,9 +497,9 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
public static class InitializedMapAndListProperties extends Foo {
private Map<String, Boolean> map = new HashMap<>();
private final Map<String, Boolean> map = new HashMap<>();
private List<String> list = new ArrayList<>();
private final List<String> list = new ArrayList<>();
public Map<String, Boolean> getMap() {
return this.map;

@ -435,7 +435,7 @@ class ConfigurationPropertiesReportEndpointTests {
private Duration duration = Duration.ofSeconds(10);
private String ignored = "dummy";
private final String ignored = "dummy";
public String getDbPassword() {
return this.dbPassword;
@ -803,7 +803,7 @@ class ConfigurationPropertiesReportEndpointTests {
private URI noPasswordUri = URI.create("http://user:@localhost:8080");
private List<String> simpleList = new ArrayList<>();
private final List<String> simpleList = new ArrayList<>();
private String rawSensitiveAddresses = "http://user:password@localhost:8080,http://user2:password2@localhost:8082";

@ -38,16 +38,17 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
class OperationMethodParameterTests {
private Method example = ReflectionUtils.findMethod(getClass(), "example", String.class, String.class);
private final Method example = ReflectionUtils.findMethod(getClass(), "example", String.class, String.class);
private Method exampleJsr305 = ReflectionUtils.findMethod(getClass(), "exampleJsr305", String.class, String.class);
private Method exampleMetaJsr305 = ReflectionUtils.findMethod(getClass(), "exampleMetaJsr305", String.class,
private final Method exampleJsr305 = ReflectionUtils.findMethod(getClass(), "exampleJsr305", String.class,
String.class);
private Method exampleJsr305NonNull = ReflectionUtils.findMethod(getClass(), "exampleJsr305NonNull", String.class,
private final Method exampleMetaJsr305 = ReflectionUtils.findMethod(getClass(), "exampleMetaJsr305", String.class,
String.class);
private final Method exampleJsr305NonNull = ReflectionUtils.findMethod(getClass(), "exampleJsr305NonNull",
String.class, String.class);
@Test
void getNameShouldReturnName() {
OperationMethodParameter parameter = new OperationMethodParameter("name", this.example.getParameters()[0]);

@ -43,9 +43,9 @@ import static org.mockito.Mockito.mock;
*/
class OperationMethodParametersTests {
private Method exampleMethod = ReflectionUtils.findMethod(getClass(), "example", String.class);
private final Method exampleMethod = ReflectionUtils.findMethod(getClass(), "example", String.class);
private Method exampleNoParamsMethod = ReflectionUtils.findMethod(getClass(), "exampleNoParams");
private final Method exampleNoParamsMethod = ReflectionUtils.findMethod(getClass(), "exampleNoParams");
@Test
void createWhenMethodIsNullShouldThrowException() {

@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*/
class OperationMethodTests {
private Method exampleMethod = ReflectionUtils.findMethod(getClass(), "example", String.class);
private final Method exampleMethod = ReflectionUtils.findMethod(getClass(), "example", String.class);
@Test
void createWhenMethodIsNullShouldThrowException() {

@ -54,9 +54,9 @@ class EndpointMBeanTests {
private static final String[] NO_SIGNATURE = {};
private TestExposableJmxEndpoint endpoint = new TestExposableJmxEndpoint(new TestJmxOperation());
private final TestExposableJmxEndpoint endpoint = new TestExposableJmxEndpoint(new TestJmxOperation());
private TestJmxOperationResponseMapper responseMapper = new TestJmxOperationResponseMapper();
private final TestJmxOperationResponseMapper responseMapper = new TestJmxOperationResponseMapper();
@Test
void createWhenResponseMapperIsNullShouldThrowException() {

@ -42,7 +42,7 @@ import static org.mockito.Mockito.spy;
*/
class JacksonJmxOperationResponseMapperTests {
private JacksonJmxOperationResponseMapper mapper = new JacksonJmxOperationResponseMapper(null);
private final JacksonJmxOperationResponseMapper mapper = new JacksonJmxOperationResponseMapper(null);
private final BasicJsonTester json = new BasicJsonTester(getClass());

@ -61,9 +61,9 @@ class JmxEndpointExporterTests {
@Spy
private EndpointObjectNameFactory objectNameFactory = new TestEndpointObjectNameFactory();
private JmxOperationResponseMapper responseMapper = new TestJmxOperationResponseMapper();
private final JmxOperationResponseMapper responseMapper = new TestJmxOperationResponseMapper();
private List<ExposableJmxEndpoint> endpoints = new ArrayList<>();
private final List<ExposableJmxEndpoint> endpoints = new ArrayList<>();
@Captor
private ArgumentCaptor<Object> objectCaptor;

@ -39,7 +39,7 @@ import static org.mockito.Mockito.mock;
*/
class MBeanInfoFactoryTests {
private MBeanInfoFactory factory = new MBeanInfoFactory(new TestJmxOperationResponseMapper());
private final MBeanInfoFactory factory = new MBeanInfoFactory(new TestJmxOperationResponseMapper());
@Test
void getMBeanInfoShouldReturnMBeanInfo() {

@ -42,7 +42,7 @@ class RequestPredicateFactoryTests {
private final RequestPredicateFactory factory = new RequestPredicateFactory(
new EndpointMediaTypes(Collections.emptyList(), Collections.emptyList()));
private String rootPath = "/root";
private final String rootPath = "/root";
@Test
void getRequestPredicateWhenHasMoreThanOneMatchAllThrowsException() {

@ -94,7 +94,7 @@ class AbstractHealthIndicatorTests {
static class TestHealthIndicator extends AbstractHealthIndicator {
private Consumer<Builder> action;
private final Consumer<Builder> action;
TestHealthIndicator(String message, Consumer<Builder> action) {
super(message);

@ -83,7 +83,7 @@ class HeapDumpWebEndpointWebIntegrationTests {
private boolean available;
private String heapDump = "HEAPDUMP";
private final String heapDump = "HEAPDUMP";
private File file;

@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
class MetricsEndpointWebIntegrationTests {
private static MeterRegistry registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock());
private static final MeterRegistry registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock());
private final ObjectMapper mapper = new ObjectMapper();

@ -39,7 +39,7 @@ import static org.mockito.Mockito.mock;
*/
class DefaultRepositoryTagsProviderTests {
private DefaultRepositoryTagsProvider provider = new DefaultRepositoryTagsProvider();
private final DefaultRepositoryTagsProvider provider = new DefaultRepositoryTagsProvider();
@Test
void repositoryTagsIncludesRepository() {

@ -61,9 +61,9 @@ class PrometheusPushGatewayManagerTests {
@Mock
private TaskScheduler scheduler;
private Duration pushRate = Duration.ofSeconds(1);
private final Duration pushRate = Duration.ofSeconds(1);
private Map<String, String> groupingKey = Collections.singletonMap("foo", "bar");
private final Map<String, String> groupingKey = Collections.singletonMap("foo", "bar");
@Captor
private ArgumentCaptor<Runnable> task;

@ -34,11 +34,11 @@ class ObservationRestTemplateCustomizerTests {
private static final String TEST_METRIC_NAME = "http.test.metric.name";
private ObservationRegistry observationRegistry = TestObservationRegistry.create();
private final ObservationRegistry observationRegistry = TestObservationRegistry.create();
private RestTemplate restTemplate = new RestTemplate();
private final RestTemplate restTemplate = new RestTemplate();
private ObservationRestTemplateCustomizer customizer = new ObservationRestTemplateCustomizer(
private final ObservationRestTemplateCustomizer customizer = new ObservationRestTemplateCustomizer(
this.observationRegistry, new DefaultClientRequestObservationConvention(TEST_METRIC_NAME));
@Test

@ -44,7 +44,7 @@ class DefaultWebClientExchangeTagsProviderTests {
private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + ".uriTemplate";
private WebClientExchangeTagsProvider tagsProvider = new DefaultWebClientExchangeTagsProvider();
private final WebClientExchangeTagsProvider tagsProvider = new DefaultWebClientExchangeTagsProvider();
private ClientRequest request;

@ -34,15 +34,15 @@ class ObservationWebClientCustomizerTests {
private static final String TEST_METRIC_NAME = "http.test.metric.name";
private TestObservationRegistry observationRegistry = TestObservationRegistry.create();
private final TestObservationRegistry observationRegistry = TestObservationRegistry.create();
private ClientRequestObservationConvention observationConvention = new DefaultClientRequestObservationConvention(
private final ClientRequestObservationConvention observationConvention = new DefaultClientRequestObservationConvention(
TEST_METRIC_NAME);
private ObservationWebClientCustomizer customizer = new ObservationWebClientCustomizer(this.observationRegistry,
this.observationConvention);
private final ObservationWebClientCustomizer customizer = new ObservationWebClientCustomizer(
this.observationRegistry, this.observationConvention);
private WebClient.Builder clientBuilder = WebClient.builder();
private final WebClient.Builder clientBuilder = WebClient.builder();
@Test
void shouldCustomizeObservationConfiguration() {

@ -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;

@ -35,9 +35,9 @@ import org.springframework.util.StringUtils;
@ConfigurationProperties(prefix = "spring.devtools")
public class DevToolsProperties {
private Restart restart = new Restart();
private final Restart restart = new Restart();
private Livereload livereload = new Livereload();
private final Livereload livereload = new Livereload();
@NestedConfigurationProperty
private final RemoteDevToolsProperties remote = new RemoteDevToolsProperties();

@ -46,9 +46,9 @@ public class RemoteDevToolsProperties {
*/
private String secretHeaderName = DEFAULT_SECRET_HEADER_NAME;
private Restart restart = new Restart();
private final Restart restart = new Restart();
private Proxy proxy = new Proxy();
private final Proxy proxy = new Proxy();
public String getContextPath() {
return this.contextPath;

@ -39,7 +39,7 @@ public class ClassPathFileSystemWatcher implements InitializingBean, DisposableB
private final FileSystemWatcher fileSystemWatcher;
private ClassPathRestartStrategy restartStrategy;
private final ClassPathRestartStrategy restartStrategy;
private ApplicationContext applicationContext;

@ -43,7 +43,7 @@ class DirectorySnapshot {
private final Date time;
private Set<FileSnapshot> files;
private final Set<FileSnapshot> files;
/**
* Create a new {@link DirectorySnapshot} for the given directory.

@ -237,7 +237,7 @@ public class FileSystemWatcher {
private Map<File, DirectorySnapshot> directories;
private SnapshotStateRepository snapshotStateRepository;
private final SnapshotStateRepository snapshotStateRepository;
private Watcher(AtomicInteger remainingScans, List<FileChangeListener> listeners, FileFilter triggerFilter,
long pollInterval, long quietPeriod, Map<File, DirectorySnapshot> directories,

@ -139,7 +139,7 @@ public class RemoteClientConfiguration implements InitializingBean {
private final String remoteUrl;
private ExecutorService executor = Executors.newSingleThreadExecutor();
private final ExecutorService executor = Executors.newSingleThreadExecutor();
LiveReloadConfiguration(DevToolsProperties properties, ClientHttpRequestFactory clientHttpRequestFactory,
@Value("${remoteUrl}") String remoteUrl) {

@ -106,7 +106,7 @@ public class Restarter {
private boolean enabled = true;
private URL[] initialUrls;
private final URL[] initialUrls;
private final String mainClassName;

@ -113,7 +113,7 @@ public class HttpTunnelConnection implements TunnelConnection {
private boolean open = true;
private AtomicLong requestSeq = new AtomicLong();
private final AtomicLong requestSeq = new AtomicLong();
public TunnelChannel(WritableByteChannel incomingChannel, Closeable closeable) {
this.forwarder = new HttpTunnelPayloadForwarder(incomingChannel);

@ -214,7 +214,7 @@ public class HttpTunnelServer {
private boolean closed;
private AtomicLong responseSeq = new AtomicLong();
private final AtomicLong responseSeq = new AtomicLong();
private long lastHttpRequestTime;
@ -364,7 +364,7 @@ public class HttpTunnelServer {
private final ServerHttpResponse response;
private ServerHttpAsyncRequestControl async;
private final ServerHttpAsyncRequestControl async;
private volatile boolean complete = false;

@ -31,7 +31,7 @@ import org.springframework.util.Assert;
*/
public class HttpTunnelServerHandler implements Handler {
private HttpTunnelServer server;
private final HttpTunnelServer server;
/**
* Create a new {@link HttpTunnelServerHandler} instance.

@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*/
class ClassPathChangedEventTests {
private Object source = new Object();
private final Object source = new Object();
@Test
void changeSetMustNotBeNull() {

@ -117,7 +117,7 @@ class ClassPathFileSystemWatcherTests {
static class Listener implements ApplicationListener<ClassPathChangedEvent> {
private List<ClassPathChangedEvent> events = new CopyOnWriteArrayList<>();
private final List<ClassPathChangedEvent> events = new CopyOnWriteArrayList<>();
@Override
public void onApplicationEvent(ClassPathChangedEvent event) {

@ -50,7 +50,7 @@ class FileSystemWatcherTests {
private FileSystemWatcher watcher;
private List<Set<ChangedFiles>> changes = Collections.synchronizedList(new ArrayList<>());
private final List<Set<ChangedFiles>> changes = Collections.synchronizedList(new ArrayList<>());
@TempDir
File tempDir;

@ -54,11 +54,11 @@ class DispatcherTests {
@Mock
private AccessManager accessManager;
private MockHttpServletResponse response = new MockHttpServletResponse();
private final MockHttpServletResponse response = new MockHttpServletResponse();
private ServerHttpRequest serverRequest = new ServletServerHttpRequest(new MockHttpServletRequest());
private final ServerHttpRequest serverRequest = new ServletServerHttpRequest(new MockHttpServletRequest());
private ServerHttpResponse serverResponse = new ServletServerHttpResponse(this.response);
private final ServerHttpResponse serverResponse = new ServletServerHttpResponse(this.response);
@Test
void accessManagerMustNotBeNull() {

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save