Consistent use of @Nullable in spring-test

This commit also removes nullability from two common spots: ResolvableType.getType() and TargetSource.getTarget(), both of which are never effectively null with any regular implementation. For such scenarios, a non-null empty type/target is the cleaner contract.

Issue: SPR-15540
This commit is contained in:
Juergen Hoeller
2017-06-08 22:52:57 +02:00
parent ee5fa2633a
commit fd53d2a51a
134 changed files with 812 additions and 777 deletions

View File

@@ -38,7 +38,6 @@ import org.springframework.core.type.filter.AspectJTypeFilter;
import org.springframework.core.type.filter.AssignableTypeFilter;
import org.springframework.core.type.filter.RegexPatternTypeFilter;
import org.springframework.core.type.filter.TypeFilter;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
@@ -64,7 +63,7 @@ class ComponentScanAnnotationParser {
private final BeanDefinitionRegistry registry;
public ComponentScanAnnotationParser(@Nullable Environment environment, @Nullable ResourceLoader resourceLoader,
public ComponentScanAnnotationParser(Environment environment, ResourceLoader resourceLoader,
BeanNameGenerator beanNameGenerator, BeanDefinitionRegistry registry) {
this.environment = environment;
@@ -75,9 +74,6 @@ class ComponentScanAnnotationParser {
public Set<BeanDefinitionHolder> parse(AnnotationAttributes componentScan, final String declaringClass) {
Assert.state(this.environment != null, "Environment must not be null");
Assert.state(this.resourceLoader != null, "ResourceLoader must not be null");
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(this.registry,
componentScan.getBoolean("useDefaultFilters"), this.environment, this.resourceLoader);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 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.
@@ -22,19 +22,19 @@ package org.springframework.jmx;
*/
public interface IJmxTestBean {
public int add(int x, int y);
int add(int x, int y);
public long myOperation();
long myOperation();
public int getAge();
int getAge();
public void setAge(int age);
void setAge(int age);
public void setName(String name) throws Exception;
void setName(String name) throws Exception;
public String getName();
String getName();
// used to test invalid methods that exist in the proxy interface
public void dontExposeMe();
void dontExposeMe();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -449,24 +449,21 @@ public class RmiSupportTests {
}
public static interface IBusinessBean {
public void setName(String name);
public interface IBusinessBean {
void setName(String name);
}
public static interface IWrongBusinessBean {
public void setOtherName(String name);
public interface IWrongBusinessBean {
void setOtherName(String name);
}
public static interface IRemoteBean extends Remote {
public void setName(String name) throws RemoteException;
public interface IRemoteBean extends Remote {
void setName(String name) throws RemoteException;
}