Make fields final
Closes gh-33537
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -35,7 +35,7 @@ import static org.mockito.Mockito.mock;
|
||||
*/
|
||||
class UrlHandlerMapperTests {
|
||||
|
||||
private Handler handler = mock(Handler.class);
|
||||
private final Handler handler = mock(Handler.class);
|
||||
|
||||
@Test
|
||||
void requestUriMustNotBeNull() {
|
||||
|
||||
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
*/
|
||||
class MainMethodTests {
|
||||
|
||||
private static ThreadLocal<MainMethod> mainMethod = new ThreadLocal<>();
|
||||
private static final ThreadLocal<MainMethod> mainMethod = new ThreadLocal<>();
|
||||
|
||||
private Method actualMain;
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ import static org.mockito.Mockito.mock;
|
||||
*/
|
||||
public class MockRestarter implements BeforeEachCallback, AfterEachCallback, ParameterResolver {
|
||||
|
||||
private Map<String, Object> attributes = new HashMap<>();
|
||||
private final Map<String, Object> attributes = new HashMap<>();
|
||||
|
||||
private Restarter mock = mock(Restarter.class);
|
||||
private final Restarter mock = mock(Restarter.class);
|
||||
|
||||
public Restarter getMock() {
|
||||
return this.mock;
|
||||
|
||||
@@ -38,7 +38,7 @@ import static org.mockito.Mockito.mock;
|
||||
*/
|
||||
class ClassLoaderFilesTests {
|
||||
|
||||
private ClassLoaderFiles files = new ClassLoaderFiles();
|
||||
private final ClassLoaderFiles files = new ClassLoaderFiles();
|
||||
|
||||
@Test
|
||||
void addFileNameMustNotBeNull() {
|
||||
|
||||
@@ -52,7 +52,7 @@ class DefaultSourceDirectoryUrlFilterTests {
|
||||
COMMON_POSTFIXES = Collections.unmodifiableList(postfixes);
|
||||
}
|
||||
|
||||
private DefaultSourceDirectoryUrlFilter filter = new DefaultSourceDirectoryUrlFilter();
|
||||
private final DefaultSourceDirectoryUrlFilter filter = new DefaultSourceDirectoryUrlFilter();
|
||||
|
||||
@Test
|
||||
void mavenSourceDirectory() throws Exception {
|
||||
|
||||
@@ -43,11 +43,11 @@ public class MockClientHttpRequestFactory implements ClientHttpRequestFactory {
|
||||
|
||||
private static final byte[] NO_DATA = {};
|
||||
|
||||
private AtomicLong seq = new AtomicLong();
|
||||
private final AtomicLong seq = new AtomicLong();
|
||||
|
||||
private Deque<Object> responses = new ArrayDeque<>();
|
||||
private final Deque<Object> responses = new ArrayDeque<>();
|
||||
|
||||
private List<MockClientHttpRequest> executedRequests = new ArrayList<>();
|
||||
private final List<MockClientHttpRequest> executedRequests = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException {
|
||||
|
||||
@@ -61,7 +61,7 @@ class HttpTunnelConnectionTests {
|
||||
@Mock
|
||||
private Closeable closeable;
|
||||
|
||||
private MockClientHttpRequestFactory requestFactory = new MockClientHttpRequestFactory();
|
||||
private final MockClientHttpRequestFactory requestFactory = new MockClientHttpRequestFactory();
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
|
||||
@@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
*/
|
||||
class TunnelClientTests {
|
||||
|
||||
private MockTunnelConnection tunnelConnection = new MockTunnelConnection();
|
||||
private final MockTunnelConnection tunnelConnection = new MockTunnelConnection();
|
||||
|
||||
@Test
|
||||
void listenPortMustNotBeNegative() {
|
||||
|
||||
@@ -346,11 +346,11 @@ class HttpTunnelServerTests {
|
||||
|
||||
private int timeout;
|
||||
|
||||
private BlockingDeque<ByteBuffer> outgoing = new LinkedBlockingDeque<>();
|
||||
private final BlockingDeque<ByteBuffer> outgoing = new LinkedBlockingDeque<>();
|
||||
|
||||
private ByteArrayOutputStream written = new ByteArrayOutputStream();
|
||||
private final ByteArrayOutputStream written = new ByteArrayOutputStream();
|
||||
|
||||
private AtomicBoolean open = new AtomicBoolean(true);
|
||||
private final AtomicBoolean open = new AtomicBoolean(true);
|
||||
|
||||
void setTimeout(int timeout) {
|
||||
this.timeout = timeout;
|
||||
|
||||
@@ -85,7 +85,7 @@ class SocketTargetServerConnectionTests {
|
||||
|
||||
static class MockServer {
|
||||
|
||||
private ServerSocketChannel serverSocket;
|
||||
private final ServerSocketChannel serverSocket;
|
||||
|
||||
private byte[] send;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user