Make fields final

Closes gh-33537
This commit is contained in:
Moritz Halbritter
2022-12-16 14:28:44 +01:00
parent 216d15997a
commit 725337f976
285 changed files with 445 additions and 437 deletions

View File

@@ -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() {

View File

@@ -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) {

View File

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

View File

@@ -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() {

View File

@@ -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() {

View File

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

View File

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

View File

@@ -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() {

View File

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

View File

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

View File

@@ -61,7 +61,7 @@ class HttpTunnelConnectionTests {
@Mock
private Closeable closeable;
private MockClientHttpRequestFactory requestFactory = new MockClientHttpRequestFactory();
private final MockClientHttpRequestFactory requestFactory = new MockClientHttpRequestFactory();
@BeforeEach
void setup() {

View File

@@ -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() {

View File

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

View File

@@ -85,7 +85,7 @@ class SocketTargetServerConnectionTests {
static class MockServer {
private ServerSocketChannel serverSocket;
private final ServerSocketChannel serverSocket;
private byte[] send;