Consistent use of @Nullable across the codebase (even for internals)
Beyond just formally declaring the current behavior, this revision actually enforces non-null behavior in selected signatures now, not tolerating null values anymore when not explicitly documented. It also changes some utility methods with historic null-in/null-out tolerance towards enforced non-null return values, making them a proper citizen in non-null assignments. Some issues are left as to-do: in particular a thorough revision of spring-test, and a few tests with unclear failures (ignored as "TODO: NULLABLE") to be sorted out in a follow-up commit. Issue: SPR-15540
This commit is contained in:
@@ -70,8 +70,8 @@ public class AnnotatedElementUtilsTests {
|
||||
|
||||
@Test
|
||||
public void getMetaAnnotationTypesOnNonAnnotatedClass() {
|
||||
assertNull(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class));
|
||||
assertNull(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class.getName()));
|
||||
assertTrue(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class).isEmpty());
|
||||
assertTrue(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class.getName()).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -860,12 +860,6 @@ public class AnnotationUtilsTests {
|
||||
assertEquals("value attribute: ", "webController", synthesizedComponent.value());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void synthesizeAnnotationsFromNullSources() throws Exception {
|
||||
assertNull("null annotation", synthesizeAnnotation(null, null));
|
||||
assertNull("null map", synthesizeAnnotation(null, WebMapping.class, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void synthesizeAlreadySynthesizedAnnotation() throws Exception {
|
||||
Method method = WebController.class.getMethod("handleMappedWithValueAttribute");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,7 +45,7 @@ public class OrderUtilsTests {
|
||||
|
||||
@Test
|
||||
public void getDefaultOrder() {
|
||||
assertEquals(Integer.valueOf(33), OrderUtils.getOrder(NoOrder.class, 33));
|
||||
assertEquals(33, OrderUtils.getOrder(NoOrder.class, 33));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -246,21 +246,6 @@ public class ResourceTests {
|
||||
assertThat(resource.contentLength(), is(3L));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testContentLength_withNullInputStream() throws IOException {
|
||||
AbstractResource resource = new AbstractResource() {
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
resource.contentLength();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetReadableByteChannel() throws IOException {
|
||||
Resource resource = new FileSystemResource(getClass().getResource("Resource.class").getFile());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,6 +48,7 @@ public class MockPropertySource extends PropertiesPropertySource {
|
||||
*/
|
||||
public static final String MOCK_PROPERTIES_PROPERTY_SOURCE_NAME = "mockProperties";
|
||||
|
||||
|
||||
/**
|
||||
* Create a new {@code MockPropertySource} named {@value #MOCK_PROPERTIES_PROPERTY_SOURCE_NAME}
|
||||
* that will maintain its own internal {@link Properties} instance.
|
||||
@@ -84,6 +85,7 @@ public class MockPropertySource extends PropertiesPropertySource {
|
||||
super(name, properties);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the given property on the underlying {@link Properties} object.
|
||||
*/
|
||||
|
||||
@@ -301,7 +301,6 @@ public class StringUtilsTests {
|
||||
|
||||
@Test
|
||||
public void testStripFilenameExtension() {
|
||||
assertEquals(null, StringUtils.stripFilenameExtension(null));
|
||||
assertEquals("", StringUtils.stripFilenameExtension(""));
|
||||
assertEquals("myfile", StringUtils.stripFilenameExtension("myfile"));
|
||||
assertEquals("myfile", StringUtils.stripFilenameExtension("myfile."));
|
||||
|
||||
Reference in New Issue
Block a user