Commit 43e54d38 authored by Phillip Webb's avatar Phillip Webb

Make fields private where possible

parent 01607605
...@@ -32,7 +32,7 @@ public class InMemoryAuditEventRepository implements AuditEventRepository { ...@@ -32,7 +32,7 @@ public class InMemoryAuditEventRepository implements AuditEventRepository {
private int capacity = 100; private int capacity = 100;
private Map<String, List<AuditEvent>> events = new HashMap<String, List<AuditEvent>>(); private final Map<String, List<AuditEvent>> events = new HashMap<String, List<AuditEvent>>();
/** /**
* @param capacity the capacity to set * @param capacity the capacity to set
......
...@@ -30,7 +30,7 @@ import org.springframework.util.Assert; ...@@ -30,7 +30,7 @@ import org.springframework.util.Assert;
*/ */
public class AuditApplicationEvent extends ApplicationEvent { public class AuditApplicationEvent extends ApplicationEvent {
private AuditEvent auditEvent; private final AuditEvent auditEvent;
/** /**
* Create a new {@link AuditApplicationEvent} that wraps a newly created * Create a new {@link AuditApplicationEvent} that wraps a newly created
......
...@@ -38,7 +38,7 @@ import org.springframework.context.annotation.Configuration; ...@@ -38,7 +38,7 @@ import org.springframework.context.annotation.Configuration;
public class AuditAutoConfiguration { public class AuditAutoConfiguration {
@Autowired(required = false) @Autowired(required = false)
private AuditEventRepository auditEventRepository = new InMemoryAuditEventRepository(); private final AuditEventRepository auditEventRepository = new InMemoryAuditEventRepository();
@Bean @Bean
public AuditListener auditListener() throws Exception { public AuditListener auditListener() throws Exception {
......
...@@ -340,9 +340,9 @@ public class CrshAutoConfiguration { ...@@ -340,9 +340,9 @@ public class CrshAutoConfiguration {
private static class BeanFactoryFilteringPluginDiscovery extends private static class BeanFactoryFilteringPluginDiscovery extends
ServiceLoaderDiscovery { ServiceLoaderDiscovery {
private ListableBeanFactory beanFactory; private final ListableBeanFactory beanFactory;
private String[] disabledPlugins; private final String[] disabledPlugins;
public BeanFactoryFilteringPluginDiscovery(ClassLoader classLoader, public BeanFactoryFilteringPluginDiscovery(ClassLoader classLoader,
ListableBeanFactory beanFactory, String[] disabledPlugins) ListableBeanFactory beanFactory, String[] disabledPlugins)
...@@ -409,7 +409,7 @@ public class CrshAutoConfiguration { ...@@ -409,7 +409,7 @@ public class CrshAutoConfiguration {
*/ */
private static class SimpleFileSystemDriver extends AbstractFSDriver<ResourceHandle> { private static class SimpleFileSystemDriver extends AbstractFSDriver<ResourceHandle> {
private ResourceHandle root; private final ResourceHandle root;
public SimpleFileSystemDriver(ResourceHandle handle) { public SimpleFileSystemDriver(ResourceHandle handle) {
this.root = handle; this.root = handle;
...@@ -463,7 +463,7 @@ public class CrshAutoConfiguration { ...@@ -463,7 +463,7 @@ public class CrshAutoConfiguration {
*/ */
private abstract static class ResourceHandle { private abstract static class ResourceHandle {
private String name; private final String name;
public ResourceHandle(String name) { public ResourceHandle(String name) {
this.name = name; this.name = name;
...@@ -480,7 +480,7 @@ public class CrshAutoConfiguration { ...@@ -480,7 +480,7 @@ public class CrshAutoConfiguration {
*/ */
private static class DirectoryHandle extends ResourceHandle { private static class DirectoryHandle extends ResourceHandle {
private ResourcePatternResolver resourceLoader; private final ResourcePatternResolver resourceLoader;
public DirectoryHandle(String name, ResourcePatternResolver resourceLoader) { public DirectoryHandle(String name, ResourcePatternResolver resourceLoader) {
super(name); super(name);
...@@ -505,7 +505,7 @@ public class CrshAutoConfiguration { ...@@ -505,7 +505,7 @@ public class CrshAutoConfiguration {
*/ */
private static class FileHandle extends ResourceHandle { private static class FileHandle extends ResourceHandle {
private Resource resource; private final Resource resource;
public FileHandle(String name, Resource resource) { public FileHandle(String name, Resource resource) {
super(name); super(name);
......
...@@ -78,13 +78,13 @@ public class EndpointAutoConfiguration { ...@@ -78,13 +78,13 @@ public class EndpointAutoConfiguration {
private InfoPropertiesConfiguration properties; private InfoPropertiesConfiguration properties;
@Autowired(required = false) @Autowired(required = false)
private MetricReader metricRepository = new InMemoryMetricRepository(); private final MetricReader metricRepository = new InMemoryMetricRepository();
@Autowired(required = false) @Autowired(required = false)
private PublicMetrics metrics; private PublicMetrics metrics;
@Autowired(required = false) @Autowired(required = false)
private TraceRepository traceRepository = new InMemoryTraceRepository(); private final TraceRepository traceRepository = new InMemoryTraceRepository();
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
...@@ -170,7 +170,7 @@ public class EndpointAutoConfiguration { ...@@ -170,7 +170,7 @@ public class EndpointAutoConfiguration {
protected static class InfoPropertiesConfiguration { protected static class InfoPropertiesConfiguration {
@Autowired @Autowired
private ConfigurableEnvironment environment = new StandardEnvironment(); private final ConfigurableEnvironment environment = new StandardEnvironment();
@Value("${spring.git.properties:classpath:git.properties}") @Value("${spring.git.properties:classpath:git.properties}")
private Resource gitProperties; private Resource gitProperties;
...@@ -198,7 +198,7 @@ public class EndpointAutoConfiguration { ...@@ -198,7 +198,7 @@ public class EndpointAutoConfiguration {
public static class GitInfo { public static class GitInfo {
private String branch; private String branch;
private Commit commit = new Commit(); private final Commit commit = new Commit();
public String getBranch() { public String getBranch() {
return this.branch; return this.branch;
......
...@@ -89,7 +89,7 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom ...@@ -89,7 +89,7 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom
@Conditional(ErrorTemplateMissingCondition.class) @Conditional(ErrorTemplateMissingCondition.class)
protected static class WhitelabelErrorViewConfiguration { protected static class WhitelabelErrorViewConfiguration {
private SpelView defaultErrorView = new SpelView( private final SpelView defaultErrorView = new SpelView(
"<html><body><h1>Whitelabel Error Page</h1>" "<html><body><h1>Whitelabel Error Page</h1>"
+ "<p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p>" + "<p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p>"
+ "<div id='created'>${timestamp}</div>" + "<div id='created'>${timestamp}</div>"
......
...@@ -123,7 +123,7 @@ public class MetricRepositoryAutoConfiguration { ...@@ -123,7 +123,7 @@ public class MetricRepositoryAutoConfiguration {
@Autowired(required = false) @Autowired(required = false)
@Qualifier("metricsExecutor") @Qualifier("metricsExecutor")
private Executor executor = Executors.newSingleThreadExecutor(); private final Executor executor = Executors.newSingleThreadExecutor();
@Bean @Bean
@ConditionalOnMissingBean(name = "metricsChannel") @ConditionalOnMissingBean(name = "metricsChannel")
......
...@@ -39,9 +39,9 @@ import org.springframework.core.env.Environment; ...@@ -39,9 +39,9 @@ import org.springframework.core.env.Environment;
public class BeansEndpoint extends AbstractEndpoint<List<Object>> implements public class BeansEndpoint extends AbstractEndpoint<List<Object>> implements
ApplicationContextAware { ApplicationContextAware {
private LiveBeansView liveBeansView = new LiveBeansView(); private final LiveBeansView liveBeansView = new LiveBeansView();
private JsonParser parser = JsonParserFactory.getJsonParser(); private final JsonParser parser = JsonParserFactory.getJsonParser();
public BeansEndpoint() { public BeansEndpoint() {
super("beans"); super("beans");
......
...@@ -28,7 +28,7 @@ import org.springframework.util.Assert; ...@@ -28,7 +28,7 @@ import org.springframework.util.Assert;
@ConfigurationProperties(name = "endpoints.health", ignoreUnknownFields = false) @ConfigurationProperties(name = "endpoints.health", ignoreUnknownFields = false)
public class HealthEndpoint<T> extends AbstractEndpoint<T> { public class HealthEndpoint<T> extends AbstractEndpoint<T> {
private HealthIndicator<? extends T> indicator; private final HealthIndicator<? extends T> indicator;
/** /**
* Create a new {@link HealthIndicator} instance. * Create a new {@link HealthIndicator} instance.
......
...@@ -31,7 +31,7 @@ import org.springframework.util.Assert; ...@@ -31,7 +31,7 @@ import org.springframework.util.Assert;
@ConfigurationProperties(name = "endpoints.info", ignoreUnknownFields = false) @ConfigurationProperties(name = "endpoints.info", ignoreUnknownFields = false)
public class InfoEndpoint extends AbstractEndpoint<Map<String, Object>> { public class InfoEndpoint extends AbstractEndpoint<Map<String, Object>> {
private Map<String, ? extends Object> info; private final Map<String, ? extends Object> info;
/** /**
* Create a new {@link InfoEndpoint} instance. * Create a new {@link InfoEndpoint} instance.
......
...@@ -31,7 +31,7 @@ import org.springframework.util.Assert; ...@@ -31,7 +31,7 @@ import org.springframework.util.Assert;
@ConfigurationProperties(name = "endpoints.metrics", ignoreUnknownFields = false) @ConfigurationProperties(name = "endpoints.metrics", ignoreUnknownFields = false)
public class MetricsEndpoint extends AbstractEndpoint<Map<String, Object>> { public class MetricsEndpoint extends AbstractEndpoint<Map<String, Object>> {
private PublicMetrics metrics; private final PublicMetrics metrics;
/** /**
* Create a new {@link MetricsEndpoint} instance. * Create a new {@link MetricsEndpoint} instance.
......
...@@ -31,7 +31,7 @@ import org.springframework.util.Assert; ...@@ -31,7 +31,7 @@ import org.springframework.util.Assert;
@ConfigurationProperties(name = "endpoints.trace", ignoreUnknownFields = false) @ConfigurationProperties(name = "endpoints.trace", ignoreUnknownFields = false)
public class TraceEndpoint extends AbstractEndpoint<List<Trace>> { public class TraceEndpoint extends AbstractEndpoint<List<Trace>> {
private TraceRepository repository; private final TraceRepository repository;
/** /**
* Create a new {@link TraceEndpoint} instance. * Create a new {@link TraceEndpoint} instance.
......
...@@ -31,7 +31,7 @@ import org.springframework.util.Assert; ...@@ -31,7 +31,7 @@ import org.springframework.util.Assert;
*/ */
public class VanillaPublicMetrics implements PublicMetrics { public class VanillaPublicMetrics implements PublicMetrics {
private MetricReader reader; private final MetricReader reader;
public VanillaPublicMetrics(MetricReader reader) { public VanillaPublicMetrics(MetricReader reader) {
Assert.notNull(reader, "MetricReader must not be null"); Assert.notNull(reader, "MetricReader must not be null");
......
...@@ -35,9 +35,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -35,9 +35,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@ManagedResource @ManagedResource
public class EndpointMBean { public class EndpointMBean {
private Endpoint<?> endpoint; private final Endpoint<?> endpoint;
private ObjectMapper mapper = new ObjectMapper(); private final ObjectMapper mapper = new ObjectMapper();
public EndpointMBean(String beanName, Endpoint<?> endpoint) { public EndpointMBean(String beanName, Endpoint<?> endpoint) {
Assert.notNull(beanName, "BeanName must not be null"); Assert.notNull(beanName, "BeanName must not be null");
......
...@@ -66,7 +66,7 @@ public class EndpointMBeanExporter extends MBeanExporter implements SmartLifecyc ...@@ -66,7 +66,7 @@ public class EndpointMBeanExporter extends MBeanExporter implements SmartLifecyc
private final MetadataNamingStrategy defaultNamingStrategy = new MetadataNamingStrategy( private final MetadataNamingStrategy defaultNamingStrategy = new MetadataNamingStrategy(
this.attributeSource); this.attributeSource);
private Set<Endpoint<?>> registeredEndpoints = new HashSet<Endpoint<?>>(); private final Set<Endpoint<?>> registeredEndpoints = new HashSet<Endpoint<?>>();
private volatile boolean autoStartup = true; private volatile boolean autoStartup = true;
......
...@@ -50,7 +50,7 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl ...@@ -50,7 +50,7 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
public class EndpointHandlerMapping extends RequestMappingHandlerMapping implements public class EndpointHandlerMapping extends RequestMappingHandlerMapping implements
ApplicationContextAware { ApplicationContextAware {
private Set<? extends MvcEndpoint> endpoints; private final Set<? extends MvcEndpoint> endpoints;
private String prefix = ""; private String prefix = "";
......
...@@ -54,7 +54,7 @@ public class JolokiaMvcEndpoint implements MvcEndpoint, InitializingBean, ...@@ -54,7 +54,7 @@ public class JolokiaMvcEndpoint implements MvcEndpoint, InitializingBean,
private boolean enabled = true; private boolean enabled = true;
private ServletWrappingController controller = new ServletWrappingController(); private final ServletWrappingController controller = new ServletWrappingController();
public JolokiaMvcEndpoint() { public JolokiaMvcEndpoint() {
this.path = "/jolokia"; this.path = "/jolokia";
...@@ -123,7 +123,7 @@ public class JolokiaMvcEndpoint implements MvcEndpoint, InitializingBean, ...@@ -123,7 +123,7 @@ public class JolokiaMvcEndpoint implements MvcEndpoint, InitializingBean,
private static class PathStripper extends HttpServletRequestWrapper { private static class PathStripper extends HttpServletRequestWrapper {
private String path; private final String path;
public PathStripper(HttpServletRequest request, String path) { public PathStripper(HttpServletRequest request, String path) {
super(request); super(request);
......
...@@ -39,7 +39,7 @@ public class MvcEndpoints implements ApplicationContextAware, InitializingBean { ...@@ -39,7 +39,7 @@ public class MvcEndpoints implements ApplicationContextAware, InitializingBean {
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
private Set<MvcEndpoint> endpoints = new HashSet<MvcEndpoint>(); private final Set<MvcEndpoint> endpoints = new HashSet<MvcEndpoint>();
private Set<Class<?>> customTypes; private Set<Class<?>> customTypes;
......
...@@ -36,9 +36,9 @@ import org.springframework.boot.actuate.metrics.writer.Delta; ...@@ -36,9 +36,9 @@ import org.springframework.boot.actuate.metrics.writer.Delta;
public class InMemoryMetricRepository implements MetricRepository, MultiMetricRepository, public class InMemoryMetricRepository implements MetricRepository, MultiMetricRepository,
PrefixMetricReader { PrefixMetricReader {
private SimpleInMemoryRepository<Metric<?>> metrics = new SimpleInMemoryRepository<Metric<?>>(); private final SimpleInMemoryRepository<Metric<?>> metrics = new SimpleInMemoryRepository<Metric<?>>();
private Collection<String> groups = new HashSet<String>(); private final Collection<String> groups = new HashSet<String>();
@Override @Override
public void increment(Delta<?> delta) { public void increment(Delta<?> delta) {
......
...@@ -47,11 +47,11 @@ public class RedisMetricRepository implements MetricRepository { ...@@ -47,11 +47,11 @@ public class RedisMetricRepository implements MetricRepository {
private String keys = this.prefix + "keys"; private String keys = this.prefix + "keys";
private BoundZSetOperations<String, String> zSetOperations; private final BoundZSetOperations<String, String> zSetOperations;
private RedisOperations<String, String> redisOperations; private final RedisOperations<String, String> redisOperations;
private ValueOperations<String, Long> longOperations; private final ValueOperations<String, Long> longOperations;
public RedisMetricRepository(RedisConnectionFactory redisConnectionFactory) { public RedisMetricRepository(RedisConnectionFactory redisConnectionFactory) {
Assert.notNull(redisConnectionFactory, "RedisConnectionFactory must not be null"); Assert.notNull(redisConnectionFactory, "RedisConnectionFactory must not be null");
......
...@@ -46,9 +46,9 @@ public class RedisMultiMetricRepository implements MultiMetricRepository { ...@@ -46,9 +46,9 @@ public class RedisMultiMetricRepository implements MultiMetricRepository {
private String keys = this.prefix + "keys"; private String keys = this.prefix + "keys";
private BoundZSetOperations<String, String> zSetOperations; private final BoundZSetOperations<String, String> zSetOperations;
private RedisOperations<String, String> redisOperations; private final RedisOperations<String, String> redisOperations;
public RedisMultiMetricRepository(RedisConnectionFactory redisConnectionFactory) { public RedisMultiMetricRepository(RedisConnectionFactory redisConnectionFactory) {
Assert.notNull(redisConnectionFactory, "RedisConnectionFactory must not be null"); Assert.notNull(redisConnectionFactory, "RedisConnectionFactory must not be null");
......
...@@ -32,7 +32,7 @@ import org.springframework.boot.actuate.metrics.writer.MetricWriter; ...@@ -32,7 +32,7 @@ import org.springframework.boot.actuate.metrics.writer.MetricWriter;
*/ */
public class InMemoryRichGaugeRepository implements RichGaugeRepository { public class InMemoryRichGaugeRepository implements RichGaugeRepository {
private SimpleInMemoryRepository<RichGauge> repository = new SimpleInMemoryRepository<RichGauge>(); private final SimpleInMemoryRepository<RichGauge> repository = new SimpleInMemoryRepository<RichGauge>();
@Override @Override
public void increment(Delta<?> delta) { public void increment(Delta<?> delta) {
......
...@@ -30,9 +30,9 @@ import java.util.concurrent.ConcurrentSkipListMap; ...@@ -30,9 +30,9 @@ import java.util.concurrent.ConcurrentSkipListMap;
*/ */
public class SimpleInMemoryRepository<T> { public class SimpleInMemoryRepository<T> {
private ConcurrentNavigableMap<String, T> values = new ConcurrentSkipListMap<String, T>(); private final ConcurrentNavigableMap<String, T> values = new ConcurrentSkipListMap<String, T>();
private ConcurrentMap<String, Object> locks = new ConcurrentHashMap<String, Object>(); private final ConcurrentMap<String, Object> locks = new ConcurrentHashMap<String, Object>();
public static interface Callback<T> { public static interface Callback<T> {
T modify(T current); T modify(T current);
......
...@@ -29,7 +29,7 @@ import org.springframework.boot.actuate.metrics.Metric; ...@@ -29,7 +29,7 @@ import org.springframework.boot.actuate.metrics.Metric;
*/ */
public class CompositeMetricWriter implements MetricWriter { public class CompositeMetricWriter implements MetricWriter {
private List<MetricWriter> writers = new ArrayList<MetricWriter>(); private final List<MetricWriter> writers = new ArrayList<MetricWriter>();
public CompositeMetricWriter(MetricWriter... writers) { public CompositeMetricWriter(MetricWriter... writers) {
for (MetricWriter writer : writers) { for (MetricWriter writer : writers) {
......
...@@ -31,7 +31,7 @@ public class MessageChannelMetricWriter implements MetricWriter { ...@@ -31,7 +31,7 @@ public class MessageChannelMetricWriter implements MetricWriter {
private static final String METRIC_NAME = "metricName"; private static final String METRIC_NAME = "metricName";
private String DELETE = "delete"; private final String DELETE = "delete";
private final MessageChannel channel; private final MessageChannel channel;
......
...@@ -42,7 +42,7 @@ public class ManagementServerProperties implements SecurityPrequisite { ...@@ -42,7 +42,7 @@ public class ManagementServerProperties implements SecurityPrequisite {
@NotNull @NotNull
private String contextPath = ""; private String contextPath = "";
private Security security = maybeCreateSecurity(); private final Security security = maybeCreateSecurity();
/** /**
* Returns the management port or {@code null} if the * Returns the management port or {@code null} if the
......
...@@ -57,9 +57,9 @@ public class ShellProperties { ...@@ -57,9 +57,9 @@ public class ShellProperties {
private String[] disabledPlugins = new String[0]; private String[] disabledPlugins = new String[0];
private Ssh ssh = new Ssh(); private final Ssh ssh = new Ssh();
private Telnet telnet = new Telnet(); private final Telnet telnet = new Telnet();
public void setAuth(String auth) { public void setAuth(String auth) {
Assert.hasLength(auth, "Auth must not be empty"); Assert.hasLength(auth, "Auth must not be empty");
......
...@@ -31,7 +31,7 @@ public class InMemoryTraceRepository implements TraceRepository { ...@@ -31,7 +31,7 @@ public class InMemoryTraceRepository implements TraceRepository {
private int capacity = 100; private int capacity = 100;
private List<Trace> traces = new ArrayList<Trace>(); private final List<Trace> traces = new ArrayList<Trace>();
/** /**
* @param capacity the capacity to set * @param capacity the capacity to set
......
...@@ -29,9 +29,9 @@ import org.springframework.util.Assert; ...@@ -29,9 +29,9 @@ import org.springframework.util.Assert;
*/ */
public final class Trace { public final class Trace {
private Date timestamp; private final Date timestamp;
private Map<String, Object> info; private final Map<String, Object> info;
public Trace(Date timestamp, Map<String, Object> info) { public Trace(Date timestamp, Map<String, Object> info) {
super(); super();
......
...@@ -55,7 +55,7 @@ public class WebRequestTraceFilter implements Filter, Ordered { ...@@ -55,7 +55,7 @@ public class WebRequestTraceFilter implements Filter, Ordered {
private int order = Integer.MAX_VALUE; private int order = Integer.MAX_VALUE;
private ObjectMapper objectMapper = new ObjectMapper(); private final ObjectMapper objectMapper = new ObjectMapper();
private BasicErrorController errorController; private BasicErrorController errorController;
......
...@@ -51,7 +51,7 @@ public class BasicErrorController implements ErrorController { ...@@ -51,7 +51,7 @@ public class BasicErrorController implements ErrorController {
private static final String ERROR_KEY = "error"; private static final String ERROR_KEY = "error";
private Log logger = LogFactory.getLog(BasicErrorController.class); private final Log logger = LogFactory.getLog(BasicErrorController.class);
@Value("${error.path:/error}") @Value("${error.path:/error}")
private String errorPath; private String errorPath;
......
...@@ -29,7 +29,7 @@ import static org.junit.Assert.assertEquals; ...@@ -29,7 +29,7 @@ import static org.junit.Assert.assertEquals;
*/ */
public class InMemoryAuditEventRepositoryTests { public class InMemoryAuditEventRepositoryTests {
private InMemoryAuditEventRepository repository = new InMemoryAuditEventRepository(); private final InMemoryAuditEventRepository repository = new InMemoryAuditEventRepository();
@Test @Test
public void testAddToCapacity() throws Exception { public void testAddToCapacity() throws Exception {
......
...@@ -56,7 +56,7 @@ import static org.junit.Assert.assertThat; ...@@ -56,7 +56,7 @@ import static org.junit.Assert.assertThat;
*/ */
public class EndpointWebMvcAutoConfigurationTests { public class EndpointWebMvcAutoConfigurationTests {
private AnnotationConfigEmbeddedWebApplicationContext applicationContext = new AnnotationConfigEmbeddedWebApplicationContext(); private final AnnotationConfigEmbeddedWebApplicationContext applicationContext = new AnnotationConfigEmbeddedWebApplicationContext();
@After @After
public void close() { public void close() {
......
...@@ -44,7 +44,7 @@ import static org.junit.Assert.assertThat; ...@@ -44,7 +44,7 @@ import static org.junit.Assert.assertThat;
*/ */
public class EndpointHandlerMappingTests { public class EndpointHandlerMappingTests {
private StaticApplicationContext context = new StaticApplicationContext(); private final StaticApplicationContext context = new StaticApplicationContext();
private Method method; private Method method;
@Before @Before
......
...@@ -40,7 +40,7 @@ import static org.mockito.Mockito.when; ...@@ -40,7 +40,7 @@ import static org.mockito.Mockito.when;
*/ */
public class SimpleHealthIndicatorTests { public class SimpleHealthIndicatorTests {
private SimpleHealthIndicator indicator = new SimpleHealthIndicator(); private final SimpleHealthIndicator indicator = new SimpleHealthIndicator();
private DriverManagerDataSource dataSource; private DriverManagerDataSource dataSource;
@Before @Before
......
...@@ -29,9 +29,9 @@ import static org.junit.Assert.assertEquals; ...@@ -29,9 +29,9 @@ import static org.junit.Assert.assertEquals;
*/ */
public class MetricCopyExporterTests { public class MetricCopyExporterTests {
private InMemoryMetricRepository writer = new InMemoryMetricRepository(); private final InMemoryMetricRepository writer = new InMemoryMetricRepository();
private InMemoryMetricRepository reader = new InMemoryMetricRepository(); private final InMemoryMetricRepository reader = new InMemoryMetricRepository();
private MetricCopyExporter exporter = new MetricCopyExporter(this.reader, this.writer); private final MetricCopyExporter exporter = new MetricCopyExporter(this.reader, this.writer);
@Test @Test
public void export() { public void export() {
......
...@@ -32,11 +32,11 @@ import static org.junit.Assert.assertEquals; ...@@ -32,11 +32,11 @@ import static org.junit.Assert.assertEquals;
*/ */
public class PrefixMetricGroupExporterTests { public class PrefixMetricGroupExporterTests {
private InMemoryMetricRepository reader = new InMemoryMetricRepository(); private final InMemoryMetricRepository reader = new InMemoryMetricRepository();
private InMemoryMetricRepository writer = new InMemoryMetricRepository(); private final InMemoryMetricRepository writer = new InMemoryMetricRepository();
private PrefixMetricGroupExporter exporter = new PrefixMetricGroupExporter( private final PrefixMetricGroupExporter exporter = new PrefixMetricGroupExporter(
this.reader, this.writer); this.reader, this.writer);
@Test @Test
......
...@@ -29,9 +29,9 @@ import static org.junit.Assert.assertEquals; ...@@ -29,9 +29,9 @@ import static org.junit.Assert.assertEquals;
*/ */
public class RichGaugeExporterTests { public class RichGaugeExporterTests {
private InMemoryRichGaugeRepository reader = new InMemoryRichGaugeRepository(); private final InMemoryRichGaugeRepository reader = new InMemoryRichGaugeRepository();
private InMemoryMetricRepository writer = new InMemoryMetricRepository(); private final InMemoryMetricRepository writer = new InMemoryMetricRepository();
private RichGaugeExporter exporter = new RichGaugeExporter(this.reader, this.writer); private final RichGaugeExporter exporter = new RichGaugeExporter(this.reader, this.writer);
@Test @Test
public void prefixedMetricsCopied() { public void prefixedMetricsCopied() {
......
...@@ -29,7 +29,7 @@ import static org.junit.Assert.assertEquals; ...@@ -29,7 +29,7 @@ import static org.junit.Assert.assertEquals;
*/ */
public class InMemoryMetricRepositoryTests { public class InMemoryMetricRepositoryTests {
private InMemoryMetricRepository repository = new InMemoryMetricRepository(); private final InMemoryMetricRepository repository = new InMemoryMetricRepository();
@Test @Test
public void increment() { public void increment() {
......
...@@ -31,7 +31,7 @@ import static org.junit.Assert.assertTrue; ...@@ -31,7 +31,7 @@ import static org.junit.Assert.assertTrue;
*/ */
public class InMemoryPrefixMetricRepositoryTests { public class InMemoryPrefixMetricRepositoryTests {
private InMemoryMetricRepository repository = new InMemoryMetricRepository(); private final InMemoryMetricRepository repository = new InMemoryMetricRepository();
@Test @Test
public void registeredPrefixCounted() { public void registeredPrefixCounted() {
......
...@@ -38,7 +38,7 @@ public class RedisServer implements TestRule { ...@@ -38,7 +38,7 @@ public class RedisServer implements TestRule {
protected LettuceConnectionFactory resource; protected LettuceConnectionFactory resource;
private String resourceDescription = "Redis ConnectionFactory"; private final String resourceDescription = "Redis ConnectionFactory";
private static final Log logger = LogFactory.getLog(RedisServer.class); private static final Log logger = LogFactory.getLog(RedisServer.class);
......
...@@ -26,7 +26,7 @@ import static org.junit.Assert.assertEquals; ...@@ -26,7 +26,7 @@ import static org.junit.Assert.assertEquals;
*/ */
public class InMemoryRichGaugeRepositoryTests { public class InMemoryRichGaugeRepositoryTests {
private InMemoryRichGaugeRepository repository = new InMemoryRichGaugeRepository(); private final InMemoryRichGaugeRepository repository = new InMemoryRichGaugeRepository();
@Test @Test
public void writeAndRead() { public void writeAndRead() {
......
...@@ -37,7 +37,7 @@ import static org.junit.Assert.assertTrue; ...@@ -37,7 +37,7 @@ import static org.junit.Assert.assertTrue;
*/ */
public class InMemoryRepositoryTests { public class InMemoryRepositoryTests {
private SimpleInMemoryRepository<String> repository = new SimpleInMemoryRepository<String>(); private final SimpleInMemoryRepository<String> repository = new SimpleInMemoryRepository<String>();
@Test @Test
public void setAndGet() { public void setAndGet() {
......
...@@ -29,8 +29,8 @@ import static org.junit.Assert.assertEquals; ...@@ -29,8 +29,8 @@ import static org.junit.Assert.assertEquals;
*/ */
public class CodahaleMetricWriterTests { public class CodahaleMetricWriterTests {
private MetricRegistry registry = new MetricRegistry(); private final MetricRegistry registry = new MetricRegistry();
private CodahaleMetricWriter writer = new CodahaleMetricWriter(this.registry); private final CodahaleMetricWriter writer = new CodahaleMetricWriter(this.registry);
@Test @Test
public void incrementCounter() { public void incrementCounter() {
......
...@@ -28,9 +28,9 @@ import static org.mockito.Mockito.verify; ...@@ -28,9 +28,9 @@ import static org.mockito.Mockito.verify;
*/ */
public class DefaultCounterServiceTests { public class DefaultCounterServiceTests {
private MetricWriter repository = mock(MetricWriter.class); private final MetricWriter repository = mock(MetricWriter.class);
private DefaultCounterService service = new DefaultCounterService(this.repository); private final DefaultCounterService service = new DefaultCounterService(this.repository);
@Test @Test
public void incrementPrependsCounter() { public void incrementPrependsCounter() {
......
...@@ -29,9 +29,9 @@ import static org.mockito.Mockito.verify; ...@@ -29,9 +29,9 @@ import static org.mockito.Mockito.verify;
*/ */
public class DefaultGaugeServiceTests { public class DefaultGaugeServiceTests {
private MetricWriter repository = mock(MetricWriter.class); private final MetricWriter repository = mock(MetricWriter.class);
private DefaultGaugeService service = new DefaultGaugeService(this.repository); private final DefaultGaugeService service = new DefaultGaugeService(this.repository);
@Test @Test
public void setPrependsGauge() { public void setPrependsGauge() {
......
...@@ -30,9 +30,9 @@ import static org.mockito.Mockito.verify; ...@@ -30,9 +30,9 @@ import static org.mockito.Mockito.verify;
*/ */
public class MessageChannelMetricWriterTests { public class MessageChannelMetricWriterTests {
private MessageChannel channel = mock(MessageChannel.class); private final MessageChannel channel = mock(MessageChannel.class);
private MessageChannelMetricWriter observer = new MessageChannelMetricWriter( private final MessageChannelMetricWriter observer = new MessageChannelMetricWriter(
this.channel); this.channel);
@Test @Test
......
...@@ -37,9 +37,9 @@ import static org.mockito.Mockito.verify; ...@@ -37,9 +37,9 @@ import static org.mockito.Mockito.verify;
*/ */
public class AuthenticationAuditListenerTests { public class AuthenticationAuditListenerTests {
private AuthenticationAuditListener listener = new AuthenticationAuditListener(); private final AuthenticationAuditListener listener = new AuthenticationAuditListener();
private ApplicationEventPublisher publisher = Mockito private final ApplicationEventPublisher publisher = Mockito
.mock(ApplicationEventPublisher.class); .mock(ApplicationEventPublisher.class);
@Before @Before
......
...@@ -37,9 +37,9 @@ import static org.mockito.Mockito.verify; ...@@ -37,9 +37,9 @@ import static org.mockito.Mockito.verify;
*/ */
public class AuthorizationAuditListenerTests { public class AuthorizationAuditListenerTests {
private AuthorizationAuditListener listener = new AuthorizationAuditListener(); private final AuthorizationAuditListener listener = new AuthorizationAuditListener();
private ApplicationEventPublisher publisher = Mockito private final ApplicationEventPublisher publisher = Mockito
.mock(ApplicationEventPublisher.class); .mock(ApplicationEventPublisher.class);
@Before @Before
......
...@@ -30,7 +30,7 @@ import static org.junit.Assert.assertEquals; ...@@ -30,7 +30,7 @@ import static org.junit.Assert.assertEquals;
*/ */
public class InMemoryTraceRepositoryTests { public class InMemoryTraceRepositoryTests {
private InMemoryTraceRepository repository = new InMemoryTraceRepository(); private final InMemoryTraceRepository repository = new InMemoryTraceRepository();
@Test @Test
public void capacityLimited() { public void capacityLimited() {
......
...@@ -32,7 +32,7 @@ import static org.junit.Assert.assertEquals; ...@@ -32,7 +32,7 @@ import static org.junit.Assert.assertEquals;
*/ */
public class WebRequestTraceFilterTests { public class WebRequestTraceFilterTests {
private WebRequestTraceFilter filter = new WebRequestTraceFilter( private final WebRequestTraceFilter filter = new WebRequestTraceFilter(
new InMemoryTraceRepository()); new InMemoryTraceRepository());
@Test @Test
......
...@@ -119,7 +119,7 @@ public class AutoConfigurationReport { ...@@ -119,7 +119,7 @@ public class AutoConfigurationReport {
*/ */
public static class ConditionAndOutcomes implements Iterable<ConditionAndOutcome> { public static class ConditionAndOutcomes implements Iterable<ConditionAndOutcome> {
private Set<ConditionAndOutcome> outcomes = new LinkedHashSet<ConditionAndOutcome>(); private final Set<ConditionAndOutcome> outcomes = new LinkedHashSet<ConditionAndOutcome>();
public void add(Condition condition, ConditionOutcome outcome) { public void add(Condition condition, ConditionOutcome outcome) {
this.outcomes.add(new ConditionAndOutcome(condition, outcome)); this.outcomes.add(new ConditionAndOutcome(condition, outcome));
......
...@@ -47,7 +47,7 @@ import org.springframework.util.Assert; ...@@ -47,7 +47,7 @@ import org.springframework.util.Assert;
*/ */
class AutoConfigurationSorter { class AutoConfigurationSorter {
private CachingMetadataReaderFactory metadataReaderFactory; private final CachingMetadataReaderFactory metadataReaderFactory;
public AutoConfigurationSorter(ResourceLoader resourceLoader) { public AutoConfigurationSorter(ResourceLoader resourceLoader) {
Assert.notNull(resourceLoader, "ResourceLoader must not be null"); Assert.notNull(resourceLoader, "ResourceLoader must not be null");
......
...@@ -42,9 +42,9 @@ public class BasicBatchConfigurer implements BatchConfigurer { ...@@ -42,9 +42,9 @@ public class BasicBatchConfigurer implements BatchConfigurer {
private static Log logger = LogFactory.getLog(BasicBatchConfigurer.class); private static Log logger = LogFactory.getLog(BasicBatchConfigurer.class);
private DataSource dataSource; private final DataSource dataSource;
private EntityManagerFactory entityManagerFactory; private final EntityManagerFactory entityManagerFactory;
private PlatformTransactionManager transactionManager; private PlatformTransactionManager transactionManager;
......
...@@ -26,7 +26,7 @@ import org.springframework.context.ApplicationEvent; ...@@ -26,7 +26,7 @@ import org.springframework.context.ApplicationEvent;
*/ */
public class JobExecutionEvent extends ApplicationEvent { public class JobExecutionEvent extends ApplicationEvent {
private JobExecution execution; private final JobExecution execution;
/** /**
* @param execution the job execution * @param execution the job execution
......
...@@ -31,7 +31,7 @@ import org.springframework.context.ApplicationListener; ...@@ -31,7 +31,7 @@ import org.springframework.context.ApplicationListener;
public class JobExecutionExitCodeGenerator implements public class JobExecutionExitCodeGenerator implements
ApplicationListener<JobExecutionEvent>, ExitCodeGenerator { ApplicationListener<JobExecutionEvent>, ExitCodeGenerator {
private List<JobExecution> executions = new ArrayList<JobExecution>(); private final List<JobExecution> executions = new ArrayList<JobExecution>();
@Override @Override
public void onApplicationEvent(JobExecutionEvent event) { public void onApplicationEvent(JobExecutionEvent event) {
......
...@@ -53,7 +53,7 @@ public class JobLauncherCommandLineRunner implements CommandLineRunner, ...@@ -53,7 +53,7 @@ public class JobLauncherCommandLineRunner implements CommandLineRunner,
private static Log logger = LogFactory.getLog(JobLauncherCommandLineRunner.class); private static Log logger = LogFactory.getLog(JobLauncherCommandLineRunner.class);
@Autowired(required = false) @Autowired(required = false)
private JobParametersConverter converter = new DefaultJobParametersConverter(); private final JobParametersConverter converter = new DefaultJobParametersConverter();
@Autowired @Autowired
private JobLauncher jobLauncher; private JobLauncher jobLauncher;
...@@ -64,7 +64,7 @@ public class JobLauncherCommandLineRunner implements CommandLineRunner, ...@@ -64,7 +64,7 @@ public class JobLauncherCommandLineRunner implements CommandLineRunner,
private String jobName; private String jobName;
@Autowired(required = false) @Autowired(required = false)
private Collection<Job> jobs = Collections.emptySet(); private final Collection<Job> jobs = Collections.emptySet();
private ApplicationEventPublisher publisher; private ApplicationEventPublisher publisher;
......
...@@ -180,13 +180,13 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit ...@@ -180,13 +180,13 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
private static class BeanSearchSpec { private static class BeanSearchSpec {
private List<String> names = new ArrayList<String>(); private final List<String> names = new ArrayList<String>();
private List<String> types = new ArrayList<String>(); private final List<String> types = new ArrayList<String>();
private List<String> annotations = new ArrayList<String>(); private final List<String> annotations = new ArrayList<String>();
private SearchStrategy strategy; private final SearchStrategy strategy;
public BeanSearchSpec(ConditionContext context, AnnotatedTypeMetadata metadata, public BeanSearchSpec(ConditionContext context, AnnotatedTypeMetadata metadata,
Class<?> annotationType) { Class<?> annotationType) {
......
...@@ -35,7 +35,7 @@ import org.springframework.util.MultiValueMap; ...@@ -35,7 +35,7 @@ import org.springframework.util.MultiValueMap;
*/ */
class OnResourceCondition extends SpringBootCondition { class OnResourceCondition extends SpringBootCondition {
private ResourceLoader defaultResourceLoader = new DefaultResourceLoader(); private final ResourceLoader defaultResourceLoader = new DefaultResourceLoader();
@Override @Override
public ConditionOutcome getMatchOutcome(ConditionContext context, public ConditionOutcome getMatchOutcome(ConditionContext context,
......
...@@ -252,7 +252,7 @@ public class DataSourceAutoConfiguration implements EnvironmentAware { ...@@ -252,7 +252,7 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
*/ */
static class BasicDatabaseCondition extends NonEmbeddedDatabaseCondition { static class BasicDatabaseCondition extends NonEmbeddedDatabaseCondition {
private Condition tomcatCondition = new TomcatDatabaseCondition(); private final Condition tomcatCondition = new TomcatDatabaseCondition();
@Override @Override
protected String getDataSourceClassName() { protected String getDataSourceClassName() {
...@@ -286,9 +286,9 @@ public class DataSourceAutoConfiguration implements EnvironmentAware { ...@@ -286,9 +286,9 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
*/ */
static class EmbeddedDatabaseCondition extends SpringBootCondition { static class EmbeddedDatabaseCondition extends SpringBootCondition {
private SpringBootCondition tomcatCondition = new TomcatDatabaseCondition(); private final SpringBootCondition tomcatCondition = new TomcatDatabaseCondition();
private SpringBootCondition dbcpCondition = new BasicDatabaseCondition(); private final SpringBootCondition dbcpCondition = new BasicDatabaseCondition();
@Override @Override
public ConditionOutcome getMatchOutcome(ConditionContext context, public ConditionOutcome getMatchOutcome(ConditionContext context,
...@@ -311,11 +311,11 @@ public class DataSourceAutoConfiguration implements EnvironmentAware { ...@@ -311,11 +311,11 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
*/ */
static class DatabaseCondition extends SpringBootCondition { static class DatabaseCondition extends SpringBootCondition {
private SpringBootCondition tomcatCondition = new TomcatDatabaseCondition(); private final SpringBootCondition tomcatCondition = new TomcatDatabaseCondition();
private SpringBootCondition dbcpCondition = new BasicDatabaseCondition(); private final SpringBootCondition dbcpCondition = new BasicDatabaseCondition();
private SpringBootCondition embeddedCondition = new EmbeddedDatabaseCondition(); private final SpringBootCondition embeddedCondition = new EmbeddedDatabaseCondition();
@Override @Override
public ConditionOutcome getMatchOutcome(ConditionContext context, public ConditionOutcome getMatchOutcome(ConditionContext context,
......
...@@ -40,13 +40,13 @@ public class SecurityProperties implements SecurityPrequisite { ...@@ -40,13 +40,13 @@ public class SecurityProperties implements SecurityPrequisite {
private Basic basic = new Basic(); private Basic basic = new Basic();
private Headers headers = new Headers(); private final Headers headers = new Headers();
private SessionCreationPolicy sessions = SessionCreationPolicy.STATELESS; private SessionCreationPolicy sessions = SessionCreationPolicy.STATELESS;
private List<String> ignored = new ArrayList<String>(); private List<String> ignored = new ArrayList<String>();
private User user = new User(); private final User user = new User();
public Headers getHeaders() { public Headers getHeaders() {
return this.headers; return this.headers;
......
...@@ -63,7 +63,7 @@ public class ThymeleafAutoConfiguration { ...@@ -63,7 +63,7 @@ public class ThymeleafAutoConfiguration {
public static class DefaultTemplateResolverConfiguration implements EnvironmentAware { public static class DefaultTemplateResolverConfiguration implements EnvironmentAware {
@Autowired @Autowired
private ResourceLoader resourceLoader = new DefaultResourceLoader(); private final ResourceLoader resourceLoader = new DefaultResourceLoader();
private RelaxedPropertyResolver environment; private RelaxedPropertyResolver environment;
...@@ -108,10 +108,10 @@ public class ThymeleafAutoConfiguration { ...@@ -108,10 +108,10 @@ public class ThymeleafAutoConfiguration {
protected static class ThymeleafDefaultConfiguration { protected static class ThymeleafDefaultConfiguration {
@Autowired @Autowired
private Collection<ITemplateResolver> templateResolvers = Collections.emptySet(); private final Collection<ITemplateResolver> templateResolvers = Collections.emptySet();
@Autowired(required = false) @Autowired(required = false)
private Collection<IDialect> dialects = Collections.emptySet(); private final Collection<IDialect> dialects = Collections.emptySet();
@Bean @Bean
public SpringTemplateEngine templateEngine() { public SpringTemplateEngine templateEngine() {
......
...@@ -50,7 +50,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupp ...@@ -50,7 +50,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupp
*/ */
public class HttpMessageConverters implements Iterable<HttpMessageConverter<?>> { public class HttpMessageConverters implements Iterable<HttpMessageConverter<?>> {
private List<HttpMessageConverter<?>> converters; private final List<HttpMessageConverter<?>> converters;
/** /**
* Create a new {@link HttpMessageConverters} instance with the specified additional * Create a new {@link HttpMessageConverters} instance with the specified additional
......
...@@ -50,7 +50,7 @@ import com.fasterxml.jackson.datatype.joda.JodaModule; ...@@ -50,7 +50,7 @@ import com.fasterxml.jackson.datatype.joda.JodaModule;
public class HttpMessageConvertersAutoConfiguration { public class HttpMessageConvertersAutoConfiguration {
@Autowired(required = false) @Autowired(required = false)
private List<HttpMessageConverter<?>> converters = Collections.emptyList(); private final List<HttpMessageConverter<?>> converters = Collections.emptyList();
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
......
...@@ -56,7 +56,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer { ...@@ -56,7 +56,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer {
@NotNull @NotNull
private String contextPath = ""; private String contextPath = "";
private Tomcat tomcat = new Tomcat(); private final Tomcat tomcat = new Tomcat();
public Tomcat getTomcat() { public Tomcat getTomcat() {
return this.tomcat; return this.tomcat;
......
...@@ -69,7 +69,7 @@ public class WebSocketAutoConfiguration { ...@@ -69,7 +69,7 @@ public class WebSocketAutoConfiguration {
protected static class WebSocketRegistrationConfiguration implements protected static class WebSocketRegistrationConfiguration implements
BeanPostProcessor, BeanFactoryAware, WebSocketConfigurer { BeanPostProcessor, BeanFactoryAware, WebSocketConfigurer {
private Map<String, WebSocketHandler> prefixes = new HashMap<String, WebSocketHandler>(); private final Map<String, WebSocketHandler> prefixes = new HashMap<String, WebSocketHandler>();
private ListableBeanFactory beanFactory; private ListableBeanFactory beanFactory;
......
...@@ -35,7 +35,7 @@ import static org.junit.Assert.assertEquals; ...@@ -35,7 +35,7 @@ import static org.junit.Assert.assertEquals;
*/ */
public class PropertyPlaceholderAutoConfigurationTests { public class PropertyPlaceholderAutoConfigurationTests {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@After @After
public void close() { public void close() {
......
...@@ -29,7 +29,7 @@ import static org.junit.Assert.assertEquals; ...@@ -29,7 +29,7 @@ import static org.junit.Assert.assertEquals;
*/ */
public class JobExecutionExitCodeGeneratorTests { public class JobExecutionExitCodeGeneratorTests {
private JobExecutionExitCodeGenerator generator = new JobExecutionExitCodeGenerator(); private final JobExecutionExitCodeGenerator generator = new JobExecutionExitCodeGenerator();
@Test @Test
public void testExitCodeForRunning() { public void testExitCodeForRunning() {
......
...@@ -37,7 +37,7 @@ import static org.junit.Assert.assertTrue; ...@@ -37,7 +37,7 @@ import static org.junit.Assert.assertTrue;
*/ */
public class ConditionalOnBeanTests { public class ConditionalOnBeanTests {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@Test @Test
public void testNameOnBeanCondition() { public void testNameOnBeanCondition() {
......
...@@ -34,7 +34,7 @@ import static org.junit.Assert.assertTrue; ...@@ -34,7 +34,7 @@ import static org.junit.Assert.assertTrue;
*/ */
public class ConditionalOnClassTests { public class ConditionalOnClassTests {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@Test @Test
public void testVanillaOnClassCondition() { public void testVanillaOnClassCondition() {
......
...@@ -32,7 +32,7 @@ import static org.junit.Assert.assertTrue; ...@@ -32,7 +32,7 @@ import static org.junit.Assert.assertTrue;
*/ */
public class ConditionalOnExpressionTests { public class ConditionalOnExpressionTests {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@Test @Test
public void testResourceExists() { public void testResourceExists() {
......
...@@ -41,7 +41,7 @@ import static org.junit.Assert.assertTrue; ...@@ -41,7 +41,7 @@ import static org.junit.Assert.assertTrue;
@SuppressWarnings("resource") @SuppressWarnings("resource")
public class ConditionalOnMissingBeanTests { public class ConditionalOnMissingBeanTests {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@Test @Test
public void testNameOnMissingBeanCondition() { public void testNameOnMissingBeanCondition() {
......
...@@ -32,7 +32,7 @@ import static org.junit.Assert.assertTrue; ...@@ -32,7 +32,7 @@ import static org.junit.Assert.assertTrue;
*/ */
public class ConditionalOnMissingClassTests { public class ConditionalOnMissingClassTests {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@Test @Test
public void testVanillaOnClassCondition() { public void testVanillaOnClassCondition() {
......
...@@ -32,7 +32,7 @@ import static org.junit.Assert.assertTrue; ...@@ -32,7 +32,7 @@ import static org.junit.Assert.assertTrue;
*/ */
public class ConditionalOnNotWebApplicationTests { public class ConditionalOnNotWebApplicationTests {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@Test @Test
public void testWebApplication() { public void testWebApplication() {
......
...@@ -32,7 +32,7 @@ import static org.junit.Assert.assertTrue; ...@@ -32,7 +32,7 @@ import static org.junit.Assert.assertTrue;
*/ */
public class ConditionalOnResourceTests { public class ConditionalOnResourceTests {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@Test @Test
public void testResourceExists() { public void testResourceExists() {
......
...@@ -33,7 +33,7 @@ import static org.junit.Assert.assertTrue; ...@@ -33,7 +33,7 @@ import static org.junit.Assert.assertTrue;
*/ */
public class ConditionalOnWebApplicationTests { public class ConditionalOnWebApplicationTests {
private AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); private final AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
@Test @Test
public void testWebApplication() { public void testWebApplication() {
......
...@@ -30,7 +30,7 @@ import static org.junit.Assert.assertNotNull; ...@@ -30,7 +30,7 @@ import static org.junit.Assert.assertNotNull;
*/ */
public class CommonsDataSourceConfigurationTests { public class CommonsDataSourceConfigurationTests {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@Test @Test
public void testDataSourceExists() throws Exception { public void testDataSourceExists() throws Exception {
......
...@@ -54,7 +54,7 @@ import static org.junit.Assert.assertTrue; ...@@ -54,7 +54,7 @@ import static org.junit.Assert.assertTrue;
*/ */
public class DataSourceAutoConfigurationTests { public class DataSourceAutoConfigurationTests {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@Test @Test
public void testDefaultDataSourceExists() throws Exception { public void testDefaultDataSourceExists() throws Exception {
......
...@@ -33,7 +33,7 @@ import static org.junit.Assert.assertNotNull; ...@@ -33,7 +33,7 @@ import static org.junit.Assert.assertNotNull;
*/ */
public class DataSourceTransactionManagerAutoConfigurationTests { public class DataSourceTransactionManagerAutoConfigurationTests {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@Test @Test
public void testDataSourceExists() throws Exception { public void testDataSourceExists() throws Exception {
......
...@@ -38,7 +38,7 @@ import static org.junit.Assert.assertNotNull; ...@@ -38,7 +38,7 @@ import static org.junit.Assert.assertNotNull;
*/ */
public class TomcatDataSourceConfigurationTests { public class TomcatDataSourceConfigurationTests {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@After @After
public void restore() { public void restore() {
......
...@@ -28,7 +28,7 @@ import static org.junit.Assert.assertNotNull; ...@@ -28,7 +28,7 @@ import static org.junit.Assert.assertNotNull;
*/ */
public class ReactorAutoConfigurationTests { public class ReactorAutoConfigurationTests {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@Test @Test
public void reactorIsAvailable() { public void reactorIsAvailable() {
......
...@@ -38,7 +38,7 @@ import static org.mockito.Mockito.verify; ...@@ -38,7 +38,7 @@ import static org.mockito.Mockito.verify;
*/ */
public class ServerPropertiesTests { public class ServerPropertiesTests {
private ServerProperties properties = new ServerProperties(); private final ServerProperties properties = new ServerProperties();
@Test @Test
public void testAddressBinding() throws Exception { public void testAddressBinding() throws Exception {
......
...@@ -27,7 +27,7 @@ import java.util.Collection; ...@@ -27,7 +27,7 @@ import java.util.Collection;
*/ */
public abstract class OptionParsingCommand extends AbstractCommand { public abstract class OptionParsingCommand extends AbstractCommand {
private OptionHandler handler; private final OptionHandler handler;
protected OptionParsingCommand(String name, String description, OptionHandler handler) { protected OptionParsingCommand(String name, String description, OptionHandler handler) {
super(name, description); super(name, description);
......
...@@ -33,9 +33,9 @@ import org.springframework.boot.cli.util.ResourceUtils; ...@@ -33,9 +33,9 @@ import org.springframework.boot.cli.util.ResourceUtils;
*/ */
public class SourceOptions { public class SourceOptions {
private List<String> sources; private final List<String> sources;
private List<?> args; private final List<?> args;
/** /**
* Create a new {@link SourceOptions} instance. * Create a new {@link SourceOptions} instance.
......
...@@ -30,7 +30,7 @@ class AnsiString { ...@@ -30,7 +30,7 @@ class AnsiString {
private final Terminal terminal; private final Terminal terminal;
private StringBuilder value = new StringBuilder(); private final StringBuilder value = new StringBuilder();
/** /**
* Create a new {@link AnsiString} for the given {@link Terminal}. * Create a new {@link AnsiString} for the given {@link Terminal}.
......
...@@ -44,9 +44,9 @@ public class CommandCompleter extends StringsCompleter { ...@@ -44,9 +44,9 @@ public class CommandCompleter extends StringsCompleter {
private final Map<String, Completer> commandCompleters = new HashMap<String, Completer>(); private final Map<String, Completer> commandCompleters = new HashMap<String, Completer>();
private List<Command> commands = new ArrayList<Command>(); private final List<Command> commands = new ArrayList<Command>();
private ConsoleReader console; private final ConsoleReader console;
public CommandCompleter(ConsoleReader consoleReader, public CommandCompleter(ConsoleReader consoleReader,
ArgumentDelimiter argumentDelimiter, Iterable<Command> commands) { ArgumentDelimiter argumentDelimiter, Iterable<Command> commands) {
......
...@@ -62,13 +62,13 @@ public class Shell { ...@@ -62,13 +62,13 @@ public class Shell {
private static final String DEFAULT_PROMPT = "$ "; private static final String DEFAULT_PROMPT = "$ ";
private ShellCommandRunner commandRunner; private final ShellCommandRunner commandRunner;
private ConsoleReader consoleReader; private final ConsoleReader consoleReader;
private EscapeAwareWhiteSpaceArgumentDelimiter argumentDelimiter = new EscapeAwareWhiteSpaceArgumentDelimiter(); private final EscapeAwareWhiteSpaceArgumentDelimiter argumentDelimiter = new EscapeAwareWhiteSpaceArgumentDelimiter();
private Stack<String> prompts = new Stack<String>(); private final Stack<String> prompts = new Stack<String>();
/** /**
* Create a new {@link Shell} instance. * Create a new {@link Shell} instance.
......
...@@ -65,7 +65,7 @@ public class GroovyBeansTransformation implements ASTTransformation { ...@@ -65,7 +65,7 @@ public class GroovyBeansTransformation implements ASTTransformation {
private static final String SOURCE_INTERFACE = "org.springframework.boot.BeanDefinitionLoader.GroovyBeanDefinitionSource"; private static final String SOURCE_INTERFACE = "org.springframework.boot.BeanDefinitionLoader.GroovyBeanDefinitionSource";
private static final String BEANS = "beans"; private static final String BEANS = "beans";
private final SourceUnit source; private final SourceUnit source;
private ClassNode classNode; private final ClassNode classNode;
private boolean xformed = false; private boolean xformed = false;
public ClassVisitor(SourceUnit source, ClassNode classNode) { public ClassVisitor(SourceUnit source, ClassNode classNode) {
......
...@@ -48,13 +48,13 @@ import org.springframework.boot.cli.util.OutputCapture; ...@@ -48,13 +48,13 @@ import org.springframework.boot.cli.util.OutputCapture;
*/ */
public class CliTester implements TestRule { public class CliTester implements TestRule {
private OutputCapture outputCapture = new OutputCapture(); private final OutputCapture outputCapture = new OutputCapture();
private long timeout = TimeUnit.MINUTES.toMillis(6); private long timeout = TimeUnit.MINUTES.toMillis(6);
private List<AbstractCommand> commands = new ArrayList<AbstractCommand>(); private final List<AbstractCommand> commands = new ArrayList<AbstractCommand>();
private String prefix; private final String prefix;
public CliTester(String prefix) { public CliTester(String prefix) {
this.prefix = prefix; this.prefix = prefix;
......
...@@ -56,7 +56,7 @@ public class CommandRunnerTests { ...@@ -56,7 +56,7 @@ public class CommandRunnerTests {
@Mock @Mock
private Command anotherCommand; private Command anotherCommand;
private Set<Call> calls = EnumSet.noneOf(Call.class); private final Set<Call> calls = EnumSet.noneOf(Call.class);
private ClassLoader loader; private ClassLoader loader;
......
...@@ -30,7 +30,7 @@ import static org.junit.Assert.assertThat; ...@@ -30,7 +30,7 @@ import static org.junit.Assert.assertThat;
*/ */
public class EscapeAwareWhiteSpaceArgumentDelimiterTests { public class EscapeAwareWhiteSpaceArgumentDelimiterTests {
private EscapeAwareWhiteSpaceArgumentDelimiter delimiter = new EscapeAwareWhiteSpaceArgumentDelimiter(); private final EscapeAwareWhiteSpaceArgumentDelimiter delimiter = new EscapeAwareWhiteSpaceArgumentDelimiter();
@Test @Test
public void simple() throws Exception { public void simple() throws Exception {
......
...@@ -28,13 +28,13 @@ public class HotelSummary implements Serializable { ...@@ -28,13 +28,13 @@ public class HotelSummary implements Serializable {
private static final MathContext MATH_CONTEXT = new MathContext(2, private static final MathContext MATH_CONTEXT = new MathContext(2,
RoundingMode.HALF_UP); RoundingMode.HALF_UP);
private City city; private final City city;
private String name; private final String name;
private Double averageRating; private final Double averageRating;
private Integer averageRatingRounded; private final Integer averageRatingRounded;
public HotelSummary(City city, String name, Double averageRating) { public HotelSummary(City city, String name, Double averageRating) {
this.city = city; this.city = city;
......
...@@ -22,9 +22,9 @@ public class RatingCount implements Serializable { ...@@ -22,9 +22,9 @@ public class RatingCount implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Rating rating; private final Rating rating;
private long count; private final long count;
public RatingCount(Rating rating, long count) { public RatingCount(Rating rating, long count) {
this.rating = rating; this.rating = rating;
......
...@@ -82,7 +82,7 @@ class HotelServiceImpl implements HotelService { ...@@ -82,7 +82,7 @@ class HotelServiceImpl implements HotelService {
private static class ReviewsSummaryImpl implements ReviewsSummary { private static class ReviewsSummaryImpl implements ReviewsSummary {
private Map<Rating, Long> ratingCount; private final Map<Rating, Long> ratingCount;
public ReviewsSummaryImpl(List<RatingCount> ratingCounts) { public ReviewsSummaryImpl(List<RatingCount> ratingCounts) {
this.ratingCount = new HashMap<Rating, Long>(); this.ratingCount = new HashMap<Rating, Long>();
......
...@@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicLong; ...@@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicLong;
public class InMemoryMessageRespository implements MessageRepository { public class InMemoryMessageRespository implements MessageRepository {
private static AtomicLong counter = new AtomicLong(); private static AtomicLong counter = new AtomicLong();
private ConcurrentMap<Long, Message> messages = new ConcurrentHashMap<Long, Message>(); private final ConcurrentMap<Long, Message> messages = new ConcurrentHashMap<Long, Message>();
@Override @Override
public Iterable<Message> findAll() { public Iterable<Message> findAll() {
......
...@@ -34,7 +34,7 @@ import sample.ui.MessageRepository; ...@@ -34,7 +34,7 @@ import sample.ui.MessageRepository;
@Controller @Controller
@RequestMapping("/") @RequestMapping("/")
public class MessageController { public class MessageController {
private MessageRepository messageRepository; private final MessageRepository messageRepository;
@Autowired @Autowired
public MessageController(MessageRepository messageRepository) { public MessageController(MessageRepository messageRepository) {
......
...@@ -31,7 +31,7 @@ public class SimpleClientWebSocketHandler extends TextWebSocketHandler { ...@@ -31,7 +31,7 @@ public class SimpleClientWebSocketHandler extends TextWebSocketHandler {
private final GreetingService greetingService; private final GreetingService greetingService;
private CountDownLatch latch; private final CountDownLatch latch;
@Autowired @Autowired
public SimpleClientWebSocketHandler(GreetingService greetingService, public SimpleClientWebSocketHandler(GreetingService greetingService,
......
...@@ -83,7 +83,7 @@ public class SampleWebSocketsApplicationTests { ...@@ -83,7 +83,7 @@ public class SampleWebSocketsApplicationTests {
@Configuration @Configuration
static class ClientConfiguration implements CommandLineRunner { static class ClientConfiguration implements CommandLineRunner {
private CountDownLatch latch = new CountDownLatch(1); private final CountDownLatch latch = new CountDownLatch(1);
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
......
...@@ -222,7 +222,7 @@ class JarWriter { ...@@ -222,7 +222,7 @@ class JarWriter {
private static final byte[] ZIP_HEADER = new byte[] { 0x50, 0x4b, 0x03, 0x04 }; private static final byte[] ZIP_HEADER = new byte[] { 0x50, 0x4b, 0x03, 0x04 };
private byte[] header; private final byte[] header;
private ByteArrayInputStream headerStream; private ByteArrayInputStream headerStream;
......
...@@ -36,9 +36,9 @@ public class TestJarFile { ...@@ -36,9 +36,9 @@ public class TestJarFile {
private final byte[] buffer = new byte[4096]; private final byte[] buffer = new byte[4096];
private TemporaryFolder temporaryFolder; private final TemporaryFolder temporaryFolder;
private File jarSource; private final File jarSource;
public TestJarFile(TemporaryFolder temporaryFolder) throws IOException { public TestJarFile(TemporaryFolder temporaryFolder) throws IOException {
this.temporaryFolder = temporaryFolder; this.temporaryFolder = temporaryFolder;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment