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

@@ -146,7 +146,7 @@ public class FilteredClassLoader extends URLClassLoader implements SmartClassLoa
*/
public static final class ClassFilter implements Predicate<String> {
private Class<?>[] hiddenClasses;
private final Class<?>[] hiddenClasses;
private ClassFilter(Class<?>[] hiddenClasses) {
this.hiddenClasses = hiddenClasses;

View File

@@ -95,11 +95,11 @@ public class MockitoPostProcessor implements InstantiationAwareBeanPostProcessor
private final MockitoBeans mockitoBeans = new MockitoBeans();
private Map<Definition, String> beanNameRegistry = new HashMap<>();
private final Map<Definition, String> beanNameRegistry = new HashMap<>();
private Map<Field, String> fieldRegistry = new HashMap<>();
private final Map<Field, String> fieldRegistry = new HashMap<>();
private Map<String, SpyDefinition> spies = new HashMap<>();
private final Map<String, SpyDefinition> spies = new HashMap<>();
/**
* Create a new {@link MockitoPostProcessor} instance with the given initial

View File

@@ -318,7 +318,7 @@ class OutputCapture implements CapturedOutput {
*/
private static class AnsiOutputState {
private Enabled saved;
private final Enabled saved;
AnsiOutputState() {
this.saved = AnsiOutput.getEnabled();

View File

@@ -55,7 +55,7 @@ public class OutputCaptureRule implements TestRule, CapturedOutput {
private final OutputCapture delegate = new OutputCapture();
private List<Matcher<? super String>> matchers = new ArrayList<>();
private final List<Matcher<? super String>> matchers = new ArrayList<>();
@Override
public Statement apply(Statement base, Description description) {

View File

@@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*/
class AnnotatedClassFinderTests {
private AnnotatedClassFinder finder = new AnnotatedClassFinder(SpringBootConfiguration.class);
private final AnnotatedClassFinder finder = new AnnotatedClassFinder(SpringBootConfiguration.class);
@Test
void findFromClassWhenSourceIsNullShouldThrowException() {

View File

@@ -41,7 +41,7 @@ import static org.mockito.Mockito.mock;
*/
class ImportsContextCustomizerFactoryTests {
private ImportsContextCustomizerFactory factory = new ImportsContextCustomizerFactory();
private final ImportsContextCustomizerFactory factory = new ImportsContextCustomizerFactory();
@Test
void getContextCustomizerWhenHasNoImportAnnotationShouldReturnNull() {

View File

@@ -44,7 +44,7 @@ class ApplicationContextAssertTests {
private StaticApplicationContext context;
private RuntimeException failure = new RuntimeException();
private final RuntimeException failure = new RuntimeException();
@BeforeEach
void setup() {

View File

@@ -35,9 +35,9 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
class TestTypeExcludeFilterTests {
private TestTypeExcludeFilter filter = new TestTypeExcludeFilter();
private final TestTypeExcludeFilter filter = new TestTypeExcludeFilter();
private MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
private final MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
@Test
void matchesJUnit4TestClass() throws Exception {

View File

@@ -40,7 +40,7 @@ class BasicJsonTesterTests {
private static final String JSON = "{\"spring\":[\"boot\",\"framework\"]}";
private BasicJsonTester json = new BasicJsonTester(getClass());
private final BasicJsonTester json = new BasicJsonTester(getClass());
@Test
void createWhenResourceLoadClassIsNullShouldThrowException() {

View File

@@ -60,7 +60,7 @@ class JsonContentAssertTests {
private static final String NULLS = loadJson("nulls.json");
private static JSONComparator COMPARATOR = new DefaultComparator(JSONCompareMode.LENIENT);
private static final JSONComparator COMPARATOR = new DefaultComparator(JSONCompareMode.LENIENT);
@TempDir
public Path tempDir;

View File

@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
*/
class DefinitionsParserTests {
private DefinitionsParser parser = new DefinitionsParser();
private final DefinitionsParser parser = new DefinitionsParser();
@Test
void parseSingleMockBean() {

View File

@@ -45,7 +45,7 @@ import static org.mockito.Mockito.mock;
@ExtendWith(MockitoExtension.class)
class MockitoTestExecutionListenerTests {
private MockitoTestExecutionListener listener = new MockitoTestExecutionListener();
private final MockitoTestExecutionListener listener = new MockitoTestExecutionListener();
@Mock
private ApplicationContext applicationContext;

View File

@@ -43,7 +43,7 @@ class OutputCaptureTests {
private TestPrintStream systemErr;
private TestOutputCapture output = new TestOutputCapture();
private final TestOutputCapture output = new TestOutputCapture();
@BeforeEach
void replaceSystemStreams() {

View File

@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*/
class SpringBootTestRandomPortEnvironmentPostProcessorTests {
private SpringBootTestRandomPortEnvironmentPostProcessor postProcessor = new SpringBootTestRandomPortEnvironmentPostProcessor();
private final SpringBootTestRandomPortEnvironmentPostProcessor postProcessor = new SpringBootTestRandomPortEnvironmentPostProcessor();
private MockEnvironment environment;

View File

@@ -53,7 +53,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
@ExtendWith(MockitoExtension.class)
class RootUriRequestExpectationManagerTests {
private String uri = "https://example.com";
private final String uri = "https://example.com";
@Mock
private RequestExpectationManager delegate;