Refine null-safety based on IDEA warnings
See gh-28797
This commit is contained in:
@@ -77,7 +77,7 @@ public interface ObjectProvider<T> extends ObjectFactory<T>, Iterable<T> {
|
||||
* @throws BeansException in case of creation errors
|
||||
* @see #getObject()
|
||||
*/
|
||||
default T getObject(Object... args) throws BeansException {
|
||||
default T getObject(@Nullable Object... args) throws BeansException {
|
||||
throw new UnsupportedOperationException("Retrieval with arguments not supported -" +
|
||||
"for custom ObjectProvider classes, implement getObject(Object...) for your purposes");
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ class ConstructorResolver {
|
||||
|
||||
Constructor<?> constructorToUse = null;
|
||||
ArgumentsHolder argsHolderToUse = null;
|
||||
Object[] argsToUse = null;
|
||||
@Nullable Object[] argsToUse = null;
|
||||
|
||||
if (explicitArgs != null) {
|
||||
argsToUse = explicitArgs;
|
||||
@@ -227,7 +227,7 @@ class ConstructorResolver {
|
||||
Class<?>[] paramTypes = candidate.getParameterTypes();
|
||||
if (resolvedValues != null) {
|
||||
try {
|
||||
String[] paramNames = null;
|
||||
@Nullable String[] paramNames = null;
|
||||
if (resolvedValues.containsNamedArgument()) {
|
||||
paramNames = ConstructorPropertiesChecker.evaluate(candidate, parameterCount);
|
||||
if (paramNames == null) {
|
||||
@@ -437,7 +437,7 @@ class ConstructorResolver {
|
||||
argsToUse = explicitArgs;
|
||||
}
|
||||
else {
|
||||
Object[] argsToResolve = null;
|
||||
@Nullable Object[] argsToResolve = null;
|
||||
synchronized (mbd.constructorArgumentLock) {
|
||||
factoryMethodToUse = (Method) mbd.resolvedConstructorOrFactoryMethod;
|
||||
if (factoryMethodToUse != null && mbd.constructorArgumentsResolved) {
|
||||
@@ -536,7 +536,7 @@ class ConstructorResolver {
|
||||
else {
|
||||
// Resolved constructor arguments: type conversion and/or autowiring necessary.
|
||||
try {
|
||||
String[] paramNames = null;
|
||||
@Nullable String[] paramNames = null;
|
||||
if (resolvedValues != null && resolvedValues.containsNamedArgument()) {
|
||||
ParameterNameDiscoverer pnd = this.beanFactory.getParameterNameDiscoverer();
|
||||
if (pnd != null) {
|
||||
@@ -719,7 +719,7 @@ class ConstructorResolver {
|
||||
*/
|
||||
private ArgumentsHolder createArgumentArray(
|
||||
String beanName, RootBeanDefinition mbd, @Nullable ConstructorArgumentValues resolvedValues,
|
||||
BeanWrapper bw, Class<?>[] paramTypes, String @Nullable [] paramNames, Executable executable,
|
||||
BeanWrapper bw, Class<?>[] paramTypes, @Nullable String @Nullable [] paramNames, Executable executable,
|
||||
boolean autowiring, boolean fallback) throws UnsatisfiedDependencyException {
|
||||
|
||||
TypeConverter customConverter = this.beanFactory.getCustomTypeConverter();
|
||||
|
||||
@@ -422,7 +422,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
return resolved;
|
||||
}
|
||||
@Override
|
||||
public T getObject(Object... args) throws BeansException {
|
||||
public T getObject(@Nullable Object... args) throws BeansException {
|
||||
T resolved = resolveBean(requiredType, args, false);
|
||||
if (resolved == null) {
|
||||
throw new NoSuchBeanDefinitionException(requiredType);
|
||||
@@ -2147,7 +2147,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
* Create an {@link Optional} wrapper for the specified dependency.
|
||||
*/
|
||||
private Optional<?> createOptionalDependency(
|
||||
DependencyDescriptor descriptor, @Nullable String beanName, final Object... args) {
|
||||
DependencyDescriptor descriptor, @Nullable String beanName, final @Nullable Object... args) {
|
||||
|
||||
DependencyDescriptor descriptorToUse = new NestedDependencyDescriptor(descriptor) {
|
||||
@Override
|
||||
@@ -2317,7 +2317,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject(final Object... args) throws BeansException {
|
||||
public Object getObject(final @Nullable Object... args) throws BeansException {
|
||||
if (this.optional) {
|
||||
return createOptionalDependency(this.descriptor, this.beanName, args);
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory {
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public T getObject(Object... args) throws BeansException {
|
||||
public T getObject(@Nullable Object... args) throws BeansException {
|
||||
String[] beanNames = getBeanNamesForType(requiredType);
|
||||
if (beanNames.length == 1) {
|
||||
return (T) getBean(beanNames[0], args);
|
||||
|
||||
Reference in New Issue
Block a user