Merge branch '2.0.x'

This commit is contained in:
Phillip Webb
2018-05-03 12:44:58 -07:00
138 changed files with 274 additions and 269 deletions

View File

@@ -225,7 +225,7 @@ public class AutoConfigurationImportSelector
}
String[] excludes = getEnvironment()
.getProperty(PROPERTY_NAME_AUTOCONFIGURE_EXCLUDE, String[].class);
return (excludes == null ? Collections.emptyList() : Arrays.asList(excludes));
return (excludes != null ? Arrays.asList(excludes) : Collections.emptyList());
}
private List<String> filter(List<String> configurations,
@@ -273,7 +273,7 @@ public class AutoConfigurationImportSelector
protected final List<String> asList(AnnotationAttributes attributes, String name) {
String[] value = attributes.getStringArray(name);
return Arrays.asList(value == null ? new String[0] : value);
return Arrays.asList(value != null ? value : new String[0]);
}
private void fireAutoConfigurationImportEvents(List<String> configurations,

View File

@@ -213,8 +213,8 @@ class AutoConfigurationSorter {
}
Map<String, Object> attributes = getAnnotationMetadata()
.getAnnotationAttributes(AutoConfigureOrder.class.getName());
return (attributes == null ? AutoConfigureOrder.DEFAULT_ORDER
: (Integer) attributes.get("value"));
return (attributes != null ? (Integer) attributes.get("value")
: AutoConfigureOrder.DEFAULT_ORDER);
}
private boolean wasProcessed() {

View File

@@ -109,8 +109,8 @@ class ImportAutoConfigurationImportSelector extends AutoConfigurationImportSelec
for (String annotationName : ANNOTATION_NAMES) {
AnnotationAttributes merged = AnnotatedElementUtils
.getMergedAnnotationAttributes(source, annotationName);
Class<?>[] exclude = (merged == null ? null
: merged.getClassArray("exclude"));
Class<?>[] exclude = (merged != null ? merged.getClassArray("exclude")
: null);
if (exclude != null) {
for (Class<?> excludeClass : exclude) {
exclusions.add(excludeClass.getName());

View File

@@ -206,7 +206,7 @@ public class RabbitProperties {
return this.username;
}
Address address = this.parsedAddresses.get(0);
return address.username == null ? this.username : address.username;
return (address.username != null ? address.username : this.username);
}
public void setUsername(String username) {
@@ -229,7 +229,7 @@ public class RabbitProperties {
return getPassword();
}
Address address = this.parsedAddresses.get(0);
return address.password == null ? getPassword() : address.password;
return (address.password != null ? address.password : getPassword());
}
public void setPassword(String password) {
@@ -256,7 +256,7 @@ public class RabbitProperties {
return getVirtualHost();
}
Address address = this.parsedAddresses.get(0);
return address.virtualHost == null ? getVirtualHost() : address.virtualHost;
return (address.virtualHost != null ? address.virtualHost : getVirtualHost());
}
public void setVirtualHost(String virtualHost) {

View File

@@ -124,7 +124,7 @@ public class CacheAutoConfiguration {
}
private String[] append(String[] array, String value) {
String[] result = new String[array == null ? 1 : array.length + 1];
String[] result = new String[array != null ? array.length + 1 : 1];
if (array != null) {
System.arraycopy(array, 0, result, 0, array.length);
}

View File

@@ -285,9 +285,9 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
private Method[] getCandidateFactoryMethods(BeanDefinition definition,
Class<?> factoryClass) {
return shouldConsiderNonPublicMethods(definition)
return (shouldConsiderNonPublicMethods(definition)
? ReflectionUtils.getAllDeclaredMethods(factoryClass)
: factoryClass.getMethods();
: factoryClass.getMethods());
}
private boolean shouldConsiderNonPublicMethods(BeanDefinition definition) {

View File

@@ -61,7 +61,7 @@ public final class ConditionMessage {
@Override
public String toString() {
return (this.message == null ? "" : this.message);
return (this.message != null ? this.message : "");
}
@Override
@@ -358,7 +358,7 @@ public final class ConditionMessage {
* @return a built {@link ConditionMessage}
*/
public ConditionMessage items(Style style, Object... items) {
return items(style, items == null ? null : Arrays.asList(items));
return items(style, items != null ? Arrays.asList(items) : null);
}
/**
@@ -415,7 +415,7 @@ public final class ConditionMessage {
QUOTE {
@Override
protected String applyToItem(Object item) {
return (item == null ? null : "'" + item + "'");
return (item != null ? "'" + item + "'" : null);
}
};

View File

@@ -146,7 +146,7 @@ public class ConditionOutcome {
@Override
public String toString() {
return (this.message == null ? "" : this.message.toString());
return (this.message != null ? this.message.toString() : "");
}
/**

View File

@@ -284,7 +284,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
collectBeanNamesForAnnotation(names, beanFactory, annotationType,
considerHierarchy);
}
catch (ClassNotFoundException e) {
catch (ClassNotFoundException ex) {
// Continue
}
return StringUtils.toStringArray(names);

View File

@@ -44,10 +44,10 @@ class OnExpressionCondition extends SpringBootCondition {
String rawExpression = expression;
expression = context.getEnvironment().resolvePlaceholders(expression);
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
BeanExpressionResolver resolver = (beanFactory != null)
? beanFactory.getBeanExpressionResolver() : null;
BeanExpressionContext expressionContext = (beanFactory != null)
? new BeanExpressionContext(beanFactory, null) : null;
BeanExpressionResolver resolver = (beanFactory != null
? beanFactory.getBeanExpressionResolver() : null);
BeanExpressionContext expressionContext = (beanFactory != null
? new BeanExpressionContext(beanFactory, null) : null);
if (resolver == null) {
resolver = new StandardBeanExpressionResolver();
}

View File

@@ -53,7 +53,7 @@ class OnJavaCondition extends SpringBootCondition {
JavaVersion version) {
boolean match = isWithin(runningVersion, range, version);
String expected = String.format(
range == Range.EQUAL_OR_NEWER ? "(%s or newer)" : "(older than %s)",
range != Range.EQUAL_OR_NEWER ? "(older than %s)" : "(%s or newer)",
version);
ConditionMessage message = ConditionMessage
.forCondition(ConditionalOnJava.class, expected)

View File

@@ -46,8 +46,8 @@ class OnResourceCondition extends SpringBootCondition {
AnnotatedTypeMetadata metadata) {
MultiValueMap<String, Object> attributes = metadata
.getAllAnnotationAttributes(ConditionalOnResource.class.getName(), true);
ResourceLoader loader = context.getResourceLoader() == null
? this.defaultResourceLoader : context.getResourceLoader();
ResourceLoader loader = (context.getResourceLoader() != null
? context.getResourceLoader() : this.defaultResourceLoader);
List<String> locations = new ArrayList<>();
collectValues(locations, attributes.get("resources"));
Assert.isTrue(!locations.isEmpty(),

View File

@@ -80,7 +80,7 @@ class NoSuchBeanDefinitionFailureAnalyzer
cause);
StringBuilder message = new StringBuilder();
message.append(String.format("%s required %s that could not be found.%n",
description == null ? "A component" : description,
(description != null ? description : "A component"),
getBeanDescription(cause)));
if (!autoConfigurationResults.isEmpty()) {
for (AutoConfigurationResult provider : autoConfigurationResults) {
@@ -169,7 +169,7 @@ class NoSuchBeanDefinitionFailureAnalyzer
Source(String source) {
String[] tokens = source.split("#");
this.className = (tokens.length > 1 ? tokens[0] : source);
this.methodName = (tokens.length == 2 ? tokens[1] : null);
this.methodName = (tokens.length != 2 ? null : tokens[1]);
}
public String getClassName() {
@@ -229,8 +229,8 @@ class NoSuchBeanDefinitionFailureAnalyzer
private boolean hasName(MethodMetadata methodMetadata, String name) {
Map<String, Object> attributes = methodMetadata
.getAnnotationAttributes(Bean.class.getName());
String[] candidates = (attributes == null ? null
: (String[]) attributes.get("name"));
String[] candidates = (attributes != null ? (String[]) attributes.get("name")
: null);
if (candidates != null) {
for (String candidate : candidates) {
if (candidate.equals(name)) {

View File

@@ -109,7 +109,7 @@ public class FlywayProperties {
}
public String getPassword() {
return (this.password == null ? "" : this.password);
return (this.password != null ? this.password : "");
}
public void setPassword(String password) {

View File

@@ -104,7 +104,7 @@ public class HttpEncodingProperties {
}
public boolean shouldForce(Type type) {
Boolean force = (type == Type.REQUEST ? this.forceRequest : this.forceResponse);
Boolean force = (type != Type.REQUEST ? this.forceResponse : this.forceRequest);
if (force == null) {
force = this.force;
}

View File

@@ -69,7 +69,7 @@ public class HttpMessageConvertersAutoConfiguration {
@ConditionalOnMissingBean
public HttpMessageConverters messageConverters() {
return new HttpMessageConverters(
this.converters == null ? Collections.emptyList() : this.converters);
this.converters != null ? this.converters : Collections.emptyList());
}
@Configuration

View File

@@ -72,7 +72,7 @@ public class ProjectInfoAutoConfiguration {
}
protected Properties loadFrom(Resource location, String prefix) throws IOException {
String p = prefix.endsWith(".") ? prefix : prefix + ".";
String p = (prefix.endsWith(".") ? prefix : prefix + ".");
Properties source = PropertiesLoaderUtils.loadProperties(location);
Properties target = new Properties();
for (String key : source.stringPropertyNames()) {

View File

@@ -121,7 +121,7 @@ public class DataSourceAutoConfiguration {
private ClassLoader getDataSourceClassLoader(ConditionContext context) {
Class<?> dataSourceClass = DataSourceBuilder
.findType(context.getClassLoader());
return (dataSourceClass == null ? null : dataSourceClass.getClassLoader());
return (dataSourceClass != null ? dataSourceClass.getClassLoader() : null);
}
}

View File

@@ -195,7 +195,7 @@ public class JerseyAutoConfiguration implements ServletContextAware {
if (!applicationPath.startsWith("/")) {
applicationPath = "/" + applicationPath;
}
return applicationPath.equals("/") ? "/*" : applicationPath + "/*";
return (applicationPath.equals("/") ? "/*" : applicationPath + "/*");
}
@Override

View File

@@ -257,7 +257,7 @@ public class EmbeddedMongoAutoConfiguration {
Set<Feature> features) {
Assert.notNull(version, "version must not be null");
this.version = version;
this.features = (features == null ? Collections.emptySet() : features);
this.features = (features != null ? features : Collections.emptySet());
}
@Override

View File

@@ -76,7 +76,7 @@ public class TemplateAvailabilityProviders {
* @param applicationContext the source application context
*/
public TemplateAvailabilityProviders(ApplicationContext applicationContext) {
this(applicationContext == null ? null : applicationContext.getClassLoader());
this(applicationContext != null ? applicationContext.getClassLoader() : null);
}
/**
@@ -143,12 +143,12 @@ public class TemplateAvailabilityProviders {
if (provider == null) {
synchronized (this.cache) {
provider = findProvider(view, environment, classLoader, resourceLoader);
provider = (provider == null ? NONE : provider);
provider = (provider != null ? provider : NONE);
this.resolved.put(view, provider);
this.cache.put(view, provider);
}
}
return (provider == NONE ? null : provider);
return (provider != NONE ? provider : null);
}
private TemplateAvailabilityProvider findProvider(String view,

View File

@@ -91,7 +91,7 @@ public class BasicErrorController extends AbstractErrorController {
request, isIncludeStackTrace(request, MediaType.TEXT_HTML)));
response.setStatus(status.value());
ModelAndView modelAndView = resolveErrorView(request, response, status, model);
return (modelAndView == null ? new ModelAndView("error", model) : modelAndView);
return (modelAndView != null ? modelAndView : new ModelAndView("error", model));
}
@RequestMapping

View File

@@ -311,11 +311,11 @@ public class ErrorMvcAutoConfiguration {
@Override
public String resolvePlaceholder(String placeholderName) {
Expression expression = this.expressions.get(placeholderName);
return escape(expression == null ? null : expression.getValue(this.context));
return escape(expression != null ? expression.getValue(this.context) : null);
}
private String escape(Object value) {
return HtmlUtils.htmlEscape(value == null ? null : value.toString());
return HtmlUtils.htmlEscape(value != null ? value.toString() : null);
}
}