Commit 8c0c0ee5 authored by Phillip Webb's avatar Phillip Webb

Merge branch '2.0.x'

parents 36a37776 e1250859
...@@ -111,7 +111,7 @@ class CloudFoundrySecurityService { ...@@ -111,7 +111,7 @@ class CloudFoundrySecurityService {
return extractTokenKeys(this.restTemplate return extractTokenKeys(this.restTemplate
.getForObject(getUaaUrl() + "/token_keys", Map.class)); .getForObject(getUaaUrl() + "/token_keys", Map.class));
} }
catch (HttpStatusCodeException e) { catch (HttpStatusCodeException ex) {
throw new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE, throw new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE,
"UAA not reachable"); "UAA not reachable");
} }
......
...@@ -175,8 +175,8 @@ public class ConditionsReportEndpoint { ...@@ -175,8 +175,8 @@ public class ConditionsReportEndpoint {
public MessageAndConditions(ConditionAndOutcomes conditionAndOutcomes) { public MessageAndConditions(ConditionAndOutcomes conditionAndOutcomes) {
for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) { for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) {
List<MessageAndCondition> target = conditionAndOutcome.getOutcome() List<MessageAndCondition> target = (conditionAndOutcome.getOutcome()
.isMatch() ? this.matched : this.notMatched; .isMatch() ? this.matched : this.notMatched);
target.add(new MessageAndCondition(conditionAndOutcome)); target.add(new MessageAndCondition(conditionAndOutcome));
} }
} }
......
...@@ -132,9 +132,9 @@ class ManagementContextConfigurationImportSelector ...@@ -132,9 +132,9 @@ class ManagementContextConfigurationImportSelector
private int readOrder(AnnotationMetadata annotationMetadata) { private int readOrder(AnnotationMetadata annotationMetadata) {
Map<String, Object> attributes = annotationMetadata Map<String, Object> attributes = annotationMetadata
.getAnnotationAttributes(Order.class.getName()); .getAnnotationAttributes(Order.class.getName());
Integer order = (attributes == null ? null Integer order = (attributes != null ? (Integer) attributes.get("value")
: (Integer) attributes.get("value")); : null);
return (order == null ? Ordered.LOWEST_PRECEDENCE : order); return (order != null ? order : Ordered.LOWEST_PRECEDENCE);
} }
public String getClassName() { public String getClassName() {
......
...@@ -98,7 +98,7 @@ public class OrderedHealthAggregator extends AbstractHealthAggregator { ...@@ -98,7 +98,7 @@ public class OrderedHealthAggregator extends AbstractHealthAggregator {
public int compare(Status s1, Status s2) { public int compare(Status s1, Status s2) {
int i1 = this.statusOrder.indexOf(s1.getCode()); int i1 = this.statusOrder.indexOf(s1.getCode());
int i2 = this.statusOrder.indexOf(s2.getCode()); int i2 = this.statusOrder.indexOf(s2.getCode());
return (i1 < i2 ? -1 : (i1 == i2 ? s1.getCode().compareTo(s2.getCode()) : 1)); return (i1 < i2 ? -1 : (i1 != i2 ? 1 : s1.getCode().compareTo(s2.getCode())));
} }
} }
......
...@@ -112,7 +112,7 @@ public class LoggersEndpoint { ...@@ -112,7 +112,7 @@ public class LoggersEndpoint {
} }
private String getName(LogLevel level) { private String getName(LogLevel level) {
return (level == null ? null : level.name()); return (level != null ? level.name() : null);
} }
public String getConfiguredLevel() { public String getConfiguredLevel() {
......
...@@ -48,7 +48,7 @@ public class SolrHealthIndicator extends AbstractHealthIndicator { ...@@ -48,7 +48,7 @@ public class SolrHealthIndicator extends AbstractHealthIndicator {
request.setAction(CoreAdminParams.CoreAdminAction.STATUS); request.setAction(CoreAdminParams.CoreAdminAction.STATUS);
CoreAdminResponse response = request.process(this.solrClient); CoreAdminResponse response = request.process(this.solrClient);
int statusCode = response.getStatus(); int statusCode = response.getStatus();
Status status = (statusCode == 0 ? Status.UP : Status.DOWN); Status status = (statusCode != 0 ? Status.DOWN : Status.UP);
builder.status(status).withDetail("status", statusCode); builder.status(status).withDetail("status", statusCode);
} }
......
...@@ -225,7 +225,7 @@ public class AutoConfigurationImportSelector ...@@ -225,7 +225,7 @@ public class AutoConfigurationImportSelector
} }
String[] excludes = getEnvironment() String[] excludes = getEnvironment()
.getProperty(PROPERTY_NAME_AUTOCONFIGURE_EXCLUDE, String[].class); .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, private List<String> filter(List<String> configurations,
...@@ -273,7 +273,7 @@ public class AutoConfigurationImportSelector ...@@ -273,7 +273,7 @@ public class AutoConfigurationImportSelector
protected final List<String> asList(AnnotationAttributes attributes, String name) { protected final List<String> asList(AnnotationAttributes attributes, String name) {
String[] value = attributes.getStringArray(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, private void fireAutoConfigurationImportEvents(List<String> configurations,
......
...@@ -213,8 +213,8 @@ class AutoConfigurationSorter { ...@@ -213,8 +213,8 @@ class AutoConfigurationSorter {
} }
Map<String, Object> attributes = getAnnotationMetadata() Map<String, Object> attributes = getAnnotationMetadata()
.getAnnotationAttributes(AutoConfigureOrder.class.getName()); .getAnnotationAttributes(AutoConfigureOrder.class.getName());
return (attributes == null ? AutoConfigureOrder.DEFAULT_ORDER return (attributes != null ? (Integer) attributes.get("value")
: (Integer) attributes.get("value")); : AutoConfigureOrder.DEFAULT_ORDER);
} }
private boolean wasProcessed() { private boolean wasProcessed() {
......
...@@ -109,8 +109,8 @@ class ImportAutoConfigurationImportSelector extends AutoConfigurationImportSelec ...@@ -109,8 +109,8 @@ class ImportAutoConfigurationImportSelector extends AutoConfigurationImportSelec
for (String annotationName : ANNOTATION_NAMES) { for (String annotationName : ANNOTATION_NAMES) {
AnnotationAttributes merged = AnnotatedElementUtils AnnotationAttributes merged = AnnotatedElementUtils
.getMergedAnnotationAttributes(source, annotationName); .getMergedAnnotationAttributes(source, annotationName);
Class<?>[] exclude = (merged == null ? null Class<?>[] exclude = (merged != null ? merged.getClassArray("exclude")
: merged.getClassArray("exclude")); : null);
if (exclude != null) { if (exclude != null) {
for (Class<?> excludeClass : exclude) { for (Class<?> excludeClass : exclude) {
exclusions.add(excludeClass.getName()); exclusions.add(excludeClass.getName());
......
...@@ -206,7 +206,7 @@ public class RabbitProperties { ...@@ -206,7 +206,7 @@ public class RabbitProperties {
return this.username; return this.username;
} }
Address address = this.parsedAddresses.get(0); 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) { public void setUsername(String username) {
...@@ -229,7 +229,7 @@ public class RabbitProperties { ...@@ -229,7 +229,7 @@ public class RabbitProperties {
return getPassword(); return getPassword();
} }
Address address = this.parsedAddresses.get(0); 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) { public void setPassword(String password) {
...@@ -256,7 +256,7 @@ public class RabbitProperties { ...@@ -256,7 +256,7 @@ public class RabbitProperties {
return getVirtualHost(); return getVirtualHost();
} }
Address address = this.parsedAddresses.get(0); 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) { public void setVirtualHost(String virtualHost) {
......
...@@ -124,7 +124,7 @@ public class CacheAutoConfiguration { ...@@ -124,7 +124,7 @@ public class CacheAutoConfiguration {
} }
private String[] append(String[] array, String value) { 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) { if (array != null) {
System.arraycopy(array, 0, result, 0, array.length); System.arraycopy(array, 0, result, 0, array.length);
} }
......
...@@ -285,9 +285,9 @@ final class BeanTypeRegistry implements SmartInitializingSingleton { ...@@ -285,9 +285,9 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
private Method[] getCandidateFactoryMethods(BeanDefinition definition, private Method[] getCandidateFactoryMethods(BeanDefinition definition,
Class<?> factoryClass) { Class<?> factoryClass) {
return shouldConsiderNonPublicMethods(definition) return (shouldConsiderNonPublicMethods(definition)
? ReflectionUtils.getAllDeclaredMethods(factoryClass) ? ReflectionUtils.getAllDeclaredMethods(factoryClass)
: factoryClass.getMethods(); : factoryClass.getMethods());
} }
private boolean shouldConsiderNonPublicMethods(BeanDefinition definition) { private boolean shouldConsiderNonPublicMethods(BeanDefinition definition) {
......
...@@ -61,7 +61,7 @@ public final class ConditionMessage { ...@@ -61,7 +61,7 @@ public final class ConditionMessage {
@Override @Override
public String toString() { public String toString() {
return (this.message == null ? "" : this.message); return (this.message != null ? this.message : "");
} }
@Override @Override
...@@ -358,7 +358,7 @@ public final class ConditionMessage { ...@@ -358,7 +358,7 @@ public final class ConditionMessage {
* @return a built {@link ConditionMessage} * @return a built {@link ConditionMessage}
*/ */
public ConditionMessage items(Style style, Object... items) { 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 { ...@@ -415,7 +415,7 @@ public final class ConditionMessage {
QUOTE { QUOTE {
@Override @Override
protected String applyToItem(Object item) { protected String applyToItem(Object item) {
return (item == null ? null : "'" + item + "'"); return (item != null ? "'" + item + "'" : null);
} }
}; };
......
...@@ -146,7 +146,7 @@ public class ConditionOutcome { ...@@ -146,7 +146,7 @@ public class ConditionOutcome {
@Override @Override
public String toString() { public String toString() {
return (this.message == null ? "" : this.message.toString()); return (this.message != null ? this.message.toString() : "");
} }
/** /**
......
...@@ -284,7 +284,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit ...@@ -284,7 +284,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
collectBeanNamesForAnnotation(names, beanFactory, annotationType, collectBeanNamesForAnnotation(names, beanFactory, annotationType,
considerHierarchy); considerHierarchy);
} }
catch (ClassNotFoundException e) { catch (ClassNotFoundException ex) {
// Continue // Continue
} }
return StringUtils.toStringArray(names); return StringUtils.toStringArray(names);
......
...@@ -44,10 +44,10 @@ class OnExpressionCondition extends SpringBootCondition { ...@@ -44,10 +44,10 @@ class OnExpressionCondition extends SpringBootCondition {
String rawExpression = expression; String rawExpression = expression;
expression = context.getEnvironment().resolvePlaceholders(expression); expression = context.getEnvironment().resolvePlaceholders(expression);
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
BeanExpressionResolver resolver = (beanFactory != null) BeanExpressionResolver resolver = (beanFactory != null
? beanFactory.getBeanExpressionResolver() : null; ? beanFactory.getBeanExpressionResolver() : null);
BeanExpressionContext expressionContext = (beanFactory != null) BeanExpressionContext expressionContext = (beanFactory != null
? new BeanExpressionContext(beanFactory, null) : null; ? new BeanExpressionContext(beanFactory, null) : null);
if (resolver == null) { if (resolver == null) {
resolver = new StandardBeanExpressionResolver(); resolver = new StandardBeanExpressionResolver();
} }
......
...@@ -53,7 +53,7 @@ class OnJavaCondition extends SpringBootCondition { ...@@ -53,7 +53,7 @@ class OnJavaCondition extends SpringBootCondition {
JavaVersion version) { JavaVersion version) {
boolean match = isWithin(runningVersion, range, version); boolean match = isWithin(runningVersion, range, version);
String expected = String.format( 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); version);
ConditionMessage message = ConditionMessage ConditionMessage message = ConditionMessage
.forCondition(ConditionalOnJava.class, expected) .forCondition(ConditionalOnJava.class, expected)
......
...@@ -46,8 +46,8 @@ class OnResourceCondition extends SpringBootCondition { ...@@ -46,8 +46,8 @@ class OnResourceCondition extends SpringBootCondition {
AnnotatedTypeMetadata metadata) { AnnotatedTypeMetadata metadata) {
MultiValueMap<String, Object> attributes = metadata MultiValueMap<String, Object> attributes = metadata
.getAllAnnotationAttributes(ConditionalOnResource.class.getName(), true); .getAllAnnotationAttributes(ConditionalOnResource.class.getName(), true);
ResourceLoader loader = context.getResourceLoader() == null ResourceLoader loader = (context.getResourceLoader() != null
? this.defaultResourceLoader : context.getResourceLoader(); ? context.getResourceLoader() : this.defaultResourceLoader);
List<String> locations = new ArrayList<>(); List<String> locations = new ArrayList<>();
collectValues(locations, attributes.get("resources")); collectValues(locations, attributes.get("resources"));
Assert.isTrue(!locations.isEmpty(), Assert.isTrue(!locations.isEmpty(),
......
...@@ -80,7 +80,7 @@ class NoSuchBeanDefinitionFailureAnalyzer ...@@ -80,7 +80,7 @@ class NoSuchBeanDefinitionFailureAnalyzer
cause); cause);
StringBuilder message = new StringBuilder(); StringBuilder message = new StringBuilder();
message.append(String.format("%s required %s that could not be found.%n", 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))); getBeanDescription(cause)));
if (!autoConfigurationResults.isEmpty()) { if (!autoConfigurationResults.isEmpty()) {
for (AutoConfigurationResult provider : autoConfigurationResults) { for (AutoConfigurationResult provider : autoConfigurationResults) {
...@@ -169,7 +169,7 @@ class NoSuchBeanDefinitionFailureAnalyzer ...@@ -169,7 +169,7 @@ class NoSuchBeanDefinitionFailureAnalyzer
Source(String source) { Source(String source) {
String[] tokens = source.split("#"); String[] tokens = source.split("#");
this.className = (tokens.length > 1 ? tokens[0] : source); 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() { public String getClassName() {
...@@ -229,8 +229,8 @@ class NoSuchBeanDefinitionFailureAnalyzer ...@@ -229,8 +229,8 @@ class NoSuchBeanDefinitionFailureAnalyzer
private boolean hasName(MethodMetadata methodMetadata, String name) { private boolean hasName(MethodMetadata methodMetadata, String name) {
Map<String, Object> attributes = methodMetadata Map<String, Object> attributes = methodMetadata
.getAnnotationAttributes(Bean.class.getName()); .getAnnotationAttributes(Bean.class.getName());
String[] candidates = (attributes == null ? null String[] candidates = (attributes != null ? (String[]) attributes.get("name")
: (String[]) attributes.get("name")); : null);
if (candidates != null) { if (candidates != null) {
for (String candidate : candidates) { for (String candidate : candidates) {
if (candidate.equals(name)) { if (candidate.equals(name)) {
......
...@@ -109,7 +109,7 @@ public class FlywayProperties { ...@@ -109,7 +109,7 @@ public class FlywayProperties {
} }
public String getPassword() { public String getPassword() {
return (this.password == null ? "" : this.password); return (this.password != null ? this.password : "");
} }
public void setPassword(String password) { public void setPassword(String password) {
......
...@@ -104,7 +104,7 @@ public class HttpEncodingProperties { ...@@ -104,7 +104,7 @@ public class HttpEncodingProperties {
} }
public boolean shouldForce(Type type) { 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) { if (force == null) {
force = this.force; force = this.force;
} }
......
...@@ -69,7 +69,7 @@ public class HttpMessageConvertersAutoConfiguration { ...@@ -69,7 +69,7 @@ public class HttpMessageConvertersAutoConfiguration {
@ConditionalOnMissingBean @ConditionalOnMissingBean
public HttpMessageConverters messageConverters() { public HttpMessageConverters messageConverters() {
return new HttpMessageConverters( return new HttpMessageConverters(
this.converters == null ? Collections.emptyList() : this.converters); this.converters != null ? this.converters : Collections.emptyList());
} }
@Configuration @Configuration
......
...@@ -72,7 +72,7 @@ public class ProjectInfoAutoConfiguration { ...@@ -72,7 +72,7 @@ public class ProjectInfoAutoConfiguration {
} }
protected Properties loadFrom(Resource location, String prefix) throws IOException { 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 source = PropertiesLoaderUtils.loadProperties(location);
Properties target = new Properties(); Properties target = new Properties();
for (String key : source.stringPropertyNames()) { for (String key : source.stringPropertyNames()) {
......
...@@ -121,7 +121,7 @@ public class DataSourceAutoConfiguration { ...@@ -121,7 +121,7 @@ public class DataSourceAutoConfiguration {
private ClassLoader getDataSourceClassLoader(ConditionContext context) { private ClassLoader getDataSourceClassLoader(ConditionContext context) {
Class<?> dataSourceClass = DataSourceBuilder Class<?> dataSourceClass = DataSourceBuilder
.findType(context.getClassLoader()); .findType(context.getClassLoader());
return (dataSourceClass == null ? null : dataSourceClass.getClassLoader()); return (dataSourceClass != null ? dataSourceClass.getClassLoader() : null);
} }
} }
......
...@@ -195,7 +195,7 @@ public class JerseyAutoConfiguration implements ServletContextAware { ...@@ -195,7 +195,7 @@ public class JerseyAutoConfiguration implements ServletContextAware {
if (!applicationPath.startsWith("/")) { if (!applicationPath.startsWith("/")) {
applicationPath = "/" + applicationPath; applicationPath = "/" + applicationPath;
} }
return applicationPath.equals("/") ? "/*" : applicationPath + "/*"; return (applicationPath.equals("/") ? "/*" : applicationPath + "/*");
} }
@Override @Override
......
...@@ -257,7 +257,7 @@ public class EmbeddedMongoAutoConfiguration { ...@@ -257,7 +257,7 @@ public class EmbeddedMongoAutoConfiguration {
Set<Feature> features) { Set<Feature> features) {
Assert.notNull(version, "version must not be null"); Assert.notNull(version, "version must not be null");
this.version = version; this.version = version;
this.features = (features == null ? Collections.emptySet() : features); this.features = (features != null ? features : Collections.emptySet());
} }
@Override @Override
......
...@@ -76,7 +76,7 @@ public class TemplateAvailabilityProviders { ...@@ -76,7 +76,7 @@ public class TemplateAvailabilityProviders {
* @param applicationContext the source application context * @param applicationContext the source application context
*/ */
public TemplateAvailabilityProviders(ApplicationContext applicationContext) { public TemplateAvailabilityProviders(ApplicationContext applicationContext) {
this(applicationContext == null ? null : applicationContext.getClassLoader()); this(applicationContext != null ? applicationContext.getClassLoader() : null);
} }
/** /**
...@@ -143,12 +143,12 @@ public class TemplateAvailabilityProviders { ...@@ -143,12 +143,12 @@ public class TemplateAvailabilityProviders {
if (provider == null) { if (provider == null) {
synchronized (this.cache) { synchronized (this.cache) {
provider = findProvider(view, environment, classLoader, resourceLoader); provider = findProvider(view, environment, classLoader, resourceLoader);
provider = (provider == null ? NONE : provider); provider = (provider != null ? provider : NONE);
this.resolved.put(view, provider); this.resolved.put(view, provider);
this.cache.put(view, provider); this.cache.put(view, provider);
} }
} }
return (provider == NONE ? null : provider); return (provider != NONE ? provider : null);
} }
private TemplateAvailabilityProvider findProvider(String view, private TemplateAvailabilityProvider findProvider(String view,
......
...@@ -91,7 +91,7 @@ public class BasicErrorController extends AbstractErrorController { ...@@ -91,7 +91,7 @@ public class BasicErrorController extends AbstractErrorController {
request, isIncludeStackTrace(request, MediaType.TEXT_HTML))); request, isIncludeStackTrace(request, MediaType.TEXT_HTML)));
response.setStatus(status.value()); response.setStatus(status.value());
ModelAndView modelAndView = resolveErrorView(request, response, status, model); ModelAndView modelAndView = resolveErrorView(request, response, status, model);
return (modelAndView == null ? new ModelAndView("error", model) : modelAndView); return (modelAndView != null ? modelAndView : new ModelAndView("error", model));
} }
@RequestMapping @RequestMapping
......
...@@ -311,11 +311,11 @@ public class ErrorMvcAutoConfiguration { ...@@ -311,11 +311,11 @@ public class ErrorMvcAutoConfiguration {
@Override @Override
public String resolvePlaceholder(String placeholderName) { public String resolvePlaceholder(String placeholderName) {
Expression expression = this.expressions.get(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) { private String escape(Object value) {
return HtmlUtils.htmlEscape(value == null ? null : value.toString()); return HtmlUtils.htmlEscape(value != null ? value.toString() : null);
} }
} }
......
...@@ -64,7 +64,7 @@ public class SpringApplicationWebApplicationInitializer ...@@ -64,7 +64,7 @@ public class SpringApplicationWebApplicationInitializer
private Manifest getManifest(ServletContext servletContext) throws IOException { private Manifest getManifest(ServletContext servletContext) throws IOException {
InputStream stream = servletContext.getResourceAsStream("/META-INF/MANIFEST.MF"); InputStream stream = servletContext.getResourceAsStream("/META-INF/MANIFEST.MF");
return (stream == null ? null : new Manifest(stream)); return (stream != null ? new Manifest(stream) : null);
} }
@Override @Override
......
...@@ -260,7 +260,7 @@ public class CommandRunner implements Iterable<Command> { ...@@ -260,7 +260,7 @@ public class CommandRunner implements Iterable<Command> {
} }
protected boolean errorMessage(String message) { protected boolean errorMessage(String message) {
Log.error(message == null ? "Unexpected error" : message); Log.error(message != null ? message : "Unexpected error");
return message != null; return message != null;
} }
...@@ -280,8 +280,8 @@ public class CommandRunner implements Iterable<Command> { ...@@ -280,8 +280,8 @@ public class CommandRunner implements Iterable<Command> {
String usageHelp = command.getUsageHelp(); String usageHelp = command.getUsageHelp();
String description = command.getDescription(); String description = command.getDescription();
Log.info(String.format("%n %1$s %2$-15s%n %3$s", command.getName(), Log.info(String.format("%n %1$s %2$-15s%n %3$s", command.getName(),
(usageHelp == null ? "" : usageHelp), (usageHelp != null ? usageHelp : ""),
(description == null ? "" : description))); (description != null ? description : "")));
} }
} }
Log.info(""); Log.info("");
......
...@@ -230,7 +230,7 @@ abstract class ArchiveCommand extends OptionParsingCommand { ...@@ -230,7 +230,7 @@ abstract class ArchiveCommand extends OptionParsingCommand {
private String commaDelimitedClassNames(Class<?>[] classes) { private String commaDelimitedClassNames(Class<?>[] classes) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
for (int i = 0; i < classes.length; i++) { for (int i = 0; i < classes.length; i++) {
builder.append(i == 0 ? "" : ","); builder.append(i != 0 ? "," : "");
builder.append(classes[i].getName()); builder.append(classes[i].getName());
} }
return builder.toString(); return builder.toString();
......
...@@ -107,7 +107,7 @@ public class HelpCommand extends AbstractCommand { ...@@ -107,7 +107,7 @@ public class HelpCommand extends AbstractCommand {
} }
Collection<HelpExample> examples = command.getExamples(); Collection<HelpExample> examples = command.getExamples();
if (examples != null) { if (examples != null) {
Log.info(examples.size() == 1 ? "example:" : "examples:"); Log.info(examples.size() != 1 ? "examples:" : "example:");
Log.info(""); Log.info("");
for (HelpExample example : examples) { for (HelpExample example : examples) {
Log.info(" " + example.getDescription() + ":"); Log.info(" " + example.getDescription() + ":");
......
...@@ -45,7 +45,7 @@ public class HintCommand extends AbstractCommand { ...@@ -45,7 +45,7 @@ public class HintCommand extends AbstractCommand {
@Override @Override
public ExitStatus run(String... args) throws Exception { public ExitStatus run(String... args) throws Exception {
try { try {
int index = (args.length == 0 ? 0 : Integer.valueOf(args[0]) - 1); int index = (args.length != 0 ? Integer.valueOf(args[0]) - 1 : 0);
List<String> arguments = new ArrayList<>(args.length); List<String> arguments = new ArrayList<>(args.length);
for (int i = 2; i < args.length; i++) { for (int i = 2; i < args.length; i++) {
arguments.add(args[i]); arguments.add(args[i]);
......
...@@ -149,8 +149,8 @@ class InitializrServiceMetadata { ...@@ -149,8 +149,8 @@ class InitializrServiceMetadata {
} }
JSONObject type = root.getJSONObject(TYPE_EL); JSONObject type = root.getJSONObject(TYPE_EL);
JSONArray array = type.getJSONArray(VALUES_EL); JSONArray array = type.getJSONArray(VALUES_EL);
String defaultType = type.has(DEFAULT_ATTRIBUTE) String defaultType = (type.has(DEFAULT_ATTRIBUTE)
? type.getString(DEFAULT_ATTRIBUTE) : null; ? type.getString(DEFAULT_ATTRIBUTE) : null);
for (int i = 0; i < array.length(); i++) { for (int i = 0; i < array.length(); i++) {
JSONObject typeJson = array.getJSONObject(i); JSONObject typeJson = array.getJSONObject(i);
ProjectType projectType = parseType(typeJson, defaultType); ProjectType projectType = parseType(typeJson, defaultType);
...@@ -212,7 +212,7 @@ class InitializrServiceMetadata { ...@@ -212,7 +212,7 @@ class InitializrServiceMetadata {
private String getStringValue(JSONObject object, String name, String defaultValue) private String getStringValue(JSONObject object, String name, String defaultValue)
throws JSONException { throws JSONException {
return object.has(name) ? object.getString(name) : defaultValue; return (object.has(name) ? object.getString(name) : defaultValue);
} }
private Map<String, String> parseStringItems(JSONObject json) throws JSONException { private Map<String, String> parseStringItems(JSONObject json) throws JSONException {
......
...@@ -358,8 +358,8 @@ class ProjectGenerationRequest { ...@@ -358,8 +358,8 @@ class ProjectGenerationRequest {
return builder.build(); return builder.build();
} }
catch (URISyntaxException e) { catch (URISyntaxException ex) {
throw new ReportableException("Invalid service URL (" + e.getMessage() + ")"); throw new ReportableException("Invalid service URL (" + ex.getMessage() + ")");
} }
} }
...@@ -415,7 +415,7 @@ class ProjectGenerationRequest { ...@@ -415,7 +415,7 @@ class ProjectGenerationRequest {
} }
if (this.output != null) { if (this.output != null) {
int i = this.output.lastIndexOf('.'); int i = this.output.lastIndexOf('.');
return (i == -1 ? this.output : this.output.substring(0, i)); return (i != -1 ? this.output.substring(0, i) : this.output);
} }
return null; return null;
} }
......
...@@ -157,7 +157,7 @@ public class OptionHandler { ...@@ -157,7 +157,7 @@ public class OptionHandler {
OptionHelpAdapter(OptionDescriptor descriptor) { OptionHelpAdapter(OptionDescriptor descriptor) {
this.options = new LinkedHashSet<>(); this.options = new LinkedHashSet<>();
for (String option : descriptor.options()) { for (String option : descriptor.options()) {
this.options.add((option.length() == 1 ? "-" : "--") + option); this.options.add((option.length() != 1 ? "--" : "-") + option);
} }
if (this.options.contains("--cp")) { if (this.options.contains("--cp")) {
this.options.remove("--cp"); this.options.remove("--cp");
......
...@@ -73,7 +73,7 @@ public class CommandCompleter extends StringsCompleter { ...@@ -73,7 +73,7 @@ public class CommandCompleter extends StringsCompleter {
public int complete(String buffer, int cursor, List<CharSequence> candidates) { public int complete(String buffer, int cursor, List<CharSequence> candidates) {
int completionIndex = super.complete(buffer, cursor, candidates); int completionIndex = super.complete(buffer, cursor, candidates);
int spaceIndex = buffer.indexOf(' '); int spaceIndex = buffer.indexOf(' ');
String commandName = (spaceIndex == -1) ? "" : buffer.substring(0, spaceIndex); String commandName = ((spaceIndex != -1) ? buffer.substring(0, spaceIndex) : "");
if (!"".equals(commandName.trim())) { if (!"".equals(commandName.trim())) {
for (Command command : this.commands) { for (Command command : this.commands) {
if (command.getName().equals(commandName)) { if (command.getName().equals(commandName)) {
...@@ -129,7 +129,7 @@ public class CommandCompleter extends StringsCompleter { ...@@ -129,7 +129,7 @@ public class CommandCompleter extends StringsCompleter {
OptionHelpLine(OptionHelp optionHelp) { OptionHelpLine(OptionHelp optionHelp) {
StringBuilder options = new StringBuilder(); StringBuilder options = new StringBuilder();
for (String option : optionHelp.getOptions()) { for (String option : optionHelp.getOptions()) {
options.append(options.length() == 0 ? "" : ", "); options.append(options.length() != 0 ? ", " : "");
options.append(option); options.append(option);
} }
this.options = options.toString(); this.options = options.toString();
......
...@@ -140,7 +140,7 @@ public class Shell { ...@@ -140,7 +140,7 @@ public class Shell {
private void printBanner() { private void printBanner() {
String version = getClass().getPackage().getImplementationVersion(); String version = getClass().getPackage().getImplementationVersion();
version = (version == null ? "" : " (v" + version + ")"); version = (version != null ? " (v" + version + ")" : "");
System.out.println(ansi("Spring Boot", Code.BOLD).append(version, Code.FAINT)); System.out.println(ansi("Spring Boot", Code.BOLD).append(version, Code.FAINT));
System.out.println(ansi("Hit TAB to complete. Type 'help' and hit " System.out.println(ansi("Hit TAB to complete. Type 'help' and hit "
+ "RETURN for help, and 'exit' to quit.")); + "RETURN for help, and 'exit' to quit."));
......
...@@ -54,7 +54,7 @@ public class ShellPrompts { ...@@ -54,7 +54,7 @@ public class ShellPrompts {
* @return the current prompt * @return the current prompt
*/ */
public String getPrompt() { public String getPrompt() {
return this.prompts.isEmpty() ? DEFAULT_PROMPT : this.prompts.peek(); return (this.prompts.isEmpty() ? DEFAULT_PROMPT : this.prompts.peek());
} }
} }
...@@ -222,8 +222,8 @@ public class DependencyManagementBomTransformation ...@@ -222,8 +222,8 @@ public class DependencyManagementBomTransformation
return new UrlModelSource( return new UrlModelSource(
Grape.getInstance().resolve(null, dependency)[0].toURL()); Grape.getInstance().resolve(null, dependency)[0].toURL());
} }
catch (MalformedURLException e) { catch (MalformedURLException ex) {
throw new UnresolvableModelException(e.getMessage(), groupId, artifactId, throw new UnresolvableModelException(ex.getMessage(), groupId, artifactId,
version); version);
} }
} }
......
...@@ -115,7 +115,7 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader { ...@@ -115,7 +115,7 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader {
InputStream resourceStream = super.getResourceAsStream(name); InputStream resourceStream = super.getResourceAsStream(name);
if (resourceStream == null) { if (resourceStream == null) {
byte[] bytes = this.classResources.get(name); byte[] bytes = this.classResources.get(name);
resourceStream = bytes == null ? null : new ByteArrayInputStream(bytes); resourceStream = (bytes != null ? new ByteArrayInputStream(bytes) : null);
} }
return resourceStream; return resourceStream;
} }
......
...@@ -42,13 +42,13 @@ public class DependencyManagementArtifactCoordinatesResolver ...@@ -42,13 +42,13 @@ public class DependencyManagementArtifactCoordinatesResolver
@Override @Override
public String getGroupId(String artifactId) { public String getGroupId(String artifactId) {
Dependency dependency = find(artifactId); Dependency dependency = find(artifactId);
return (dependency == null ? null : dependency.getGroupId()); return (dependency != null ? dependency.getGroupId() : null);
} }
@Override @Override
public String getArtifactId(String id) { public String getArtifactId(String id) {
Dependency dependency = find(id); Dependency dependency = find(id);
return dependency == null ? null : dependency.getArtifactId(); return (dependency != null ? dependency.getArtifactId() : null);
} }
private Dependency find(String id) { private Dependency find(String id) {
...@@ -69,7 +69,7 @@ public class DependencyManagementArtifactCoordinatesResolver ...@@ -69,7 +69,7 @@ public class DependencyManagementArtifactCoordinatesResolver
@Override @Override
public String getVersion(String module) { public String getVersion(String module) {
Dependency dependency = find(module); Dependency dependency = find(module);
return dependency == null ? null : dependency.getVersion(); return (dependency != null ? dependency.getVersion() : null);
} }
} }
...@@ -197,7 +197,7 @@ public class AetherGrapeEngine implements GrapeEngine { ...@@ -197,7 +197,7 @@ public class AetherGrapeEngine implements GrapeEngine {
private boolean isTransitive(Map<?, ?> dependencyMap) { private boolean isTransitive(Map<?, ?> dependencyMap) {
Boolean transitive = (Boolean) dependencyMap.get("transitive"); Boolean transitive = (Boolean) dependencyMap.get("transitive");
return (transitive == null ? true : transitive); return (transitive != null ? transitive : true);
} }
private List<Dependency> getDependencies(DependencyResult dependencyResult) { private List<Dependency> getDependencies(DependencyResult dependencyResult) {
...@@ -219,7 +219,7 @@ public class AetherGrapeEngine implements GrapeEngine { ...@@ -219,7 +219,7 @@ public class AetherGrapeEngine implements GrapeEngine {
private GroovyClassLoader getClassLoader(Map args) { private GroovyClassLoader getClassLoader(Map args) {
GroovyClassLoader classLoader = (GroovyClassLoader) args.get("classLoader"); GroovyClassLoader classLoader = (GroovyClassLoader) args.get("classLoader");
return (classLoader == null ? this.classLoader : classLoader); return (classLoader != null ? classLoader : this.classLoader);
} }
@Override @Override
......
...@@ -51,8 +51,9 @@ public class DefaultRepositorySystemSessionAutoConfiguration ...@@ -51,8 +51,9 @@ public class DefaultRepositorySystemSessionAutoConfiguration
ProxySelector existing = session.getProxySelector(); ProxySelector existing = session.getProxySelector();
if (existing == null || !(existing instanceof CompositeProxySelector)) { if (existing == null || !(existing instanceof CompositeProxySelector)) {
JreProxySelector fallback = new JreProxySelector(); JreProxySelector fallback = new JreProxySelector();
ProxySelector selector = existing == null ? fallback ProxySelector selector = (existing != null
: new CompositeProxySelector(Arrays.asList(existing, fallback)); ? new CompositeProxySelector(Arrays.asList(existing, fallback))
: fallback);
session.setProxySelector(selector); session.setProxySelector(selector);
} }
} }
......
...@@ -67,7 +67,7 @@ public class DependencyResolutionContext { ...@@ -67,7 +67,7 @@ public class DependencyResolutionContext {
dependency = this.managedDependencyByGroupAndArtifact dependency = this.managedDependencyByGroupAndArtifact
.get(getIdentifier(groupId, artifactId)); .get(getIdentifier(groupId, artifactId));
} }
return dependency != null ? dependency.getArtifact().getVersion() : null; return (dependency != null ? dependency.getArtifact().getVersion() : null);
} }
public List<Dependency> getManagedDependencies() { public List<Dependency> getManagedDependencies() {
...@@ -104,9 +104,10 @@ public class DependencyResolutionContext { ...@@ -104,9 +104,10 @@ public class DependencyResolutionContext {
this.managedDependencyByGroupAndArtifact.put(getIdentifier(aetherDependency), this.managedDependencyByGroupAndArtifact.put(getIdentifier(aetherDependency),
aetherDependency); aetherDependency);
} }
this.dependencyManagement = this.dependencyManagement == null this.dependencyManagement = (this.dependencyManagement != null
? dependencyManagement : new CompositeDependencyManagement( ? new CompositeDependencyManagement(dependencyManagement,
dependencyManagement, this.dependencyManagement); this.dependencyManagement)
: dependencyManagement);
this.artifactCoordinatesResolver = new DependencyManagementArtifactCoordinatesResolver( this.artifactCoordinatesResolver = new DependencyManagementArtifactCoordinatesResolver(
this.dependencyManagement); this.dependencyManagement);
} }
......
...@@ -116,8 +116,8 @@ public class MavenSettingsReader { ...@@ -116,8 +116,8 @@ public class MavenSettingsReader {
try { try {
this._cipher = new DefaultPlexusCipher(); this._cipher = new DefaultPlexusCipher();
} }
catch (PlexusCipherException e) { catch (PlexusCipherException ex) {
throw new IllegalStateException(e); throw new IllegalStateException(ex);
} }
} }
......
...@@ -119,8 +119,8 @@ public abstract class AbstractHttpClientMockTests { ...@@ -119,8 +119,8 @@ public abstract class AbstractHttpClientMockTests {
try { try {
HttpEntity entity = mock(HttpEntity.class); HttpEntity entity = mock(HttpEntity.class);
given(entity.getContent()).willReturn(new ByteArrayInputStream(content)); given(entity.getContent()).willReturn(new ByteArrayInputStream(content));
Header contentTypeHeader = contentType != null Header contentTypeHeader = (contentType != null
? new BasicHeader("Content-Type", contentType) : null; ? new BasicHeader("Content-Type", contentType) : null);
given(entity.getContentType()).willReturn(contentTypeHeader); given(entity.getContentType()).willReturn(contentTypeHeader);
given(response.getEntity()).willReturn(entity); given(response.getEntity()).willReturn(entity);
return entity; return entity;
...@@ -138,7 +138,7 @@ public abstract class AbstractHttpClientMockTests { ...@@ -138,7 +138,7 @@ public abstract class AbstractHttpClientMockTests {
protected void mockHttpHeader(CloseableHttpResponse response, String headerName, protected void mockHttpHeader(CloseableHttpResponse response, String headerName,
String value) { String value) {
Header header = value != null ? new BasicHeader(headerName, value) : null; Header header = (value != null ? new BasicHeader(headerName, value) : null);
given(response.getFirstHeader(headerName)).willReturn(header); given(response.getFirstHeader(headerName)).willReturn(header);
} }
......
...@@ -85,8 +85,8 @@ public class RemoteDevToolsAutoConfiguration { ...@@ -85,8 +85,8 @@ public class RemoteDevToolsAutoConfiguration {
public HandlerMapper remoteDevToolsHealthCheckHandlerMapper() { public HandlerMapper remoteDevToolsHealthCheckHandlerMapper() {
Handler handler = new HttpStatusHandler(); Handler handler = new HttpStatusHandler();
return new UrlHandlerMapper( return new UrlHandlerMapper(
(this.serverProperties.getServlet().getContextPath() == null ? "" (this.serverProperties.getServlet().getContextPath() != null
: this.serverProperties.getServlet().getContextPath()) ? this.serverProperties.getServlet().getContextPath() : "")
+ this.properties.getRemote().getContextPath(), + this.properties.getRemote().getContextPath(),
handler); handler);
} }
...@@ -127,8 +127,8 @@ public class RemoteDevToolsAutoConfiguration { ...@@ -127,8 +127,8 @@ public class RemoteDevToolsAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean(name = "remoteRestartHandlerMapper") @ConditionalOnMissingBean(name = "remoteRestartHandlerMapper")
public UrlHandlerMapper remoteRestartHandlerMapper(HttpRestartServer server) { public UrlHandlerMapper remoteRestartHandlerMapper(HttpRestartServer server) {
String url = (this.serverProperties.getServlet().getContextPath() == null ? "" String url = (this.serverProperties.getServlet().getContextPath() != null
: this.serverProperties.getServlet().getContextPath()) ? this.serverProperties.getServlet().getContextPath() : "")
+ this.properties.getRemote().getContextPath() + "/restart"; + this.properties.getRemote().getContextPath() + "/restart";
logger.warn("Listening for remote restart updates on " + url); logger.warn("Listening for remote restart updates on " + url);
Handler handler = new HttpRestartServerHandler(server); Handler handler = new HttpRestartServerHandler(server);
......
...@@ -44,7 +44,7 @@ public class DevToolsHomePropertiesPostProcessor implements EnvironmentPostProce ...@@ -44,7 +44,7 @@ public class DevToolsHomePropertiesPostProcessor implements EnvironmentPostProce
public void postProcessEnvironment(ConfigurableEnvironment environment, public void postProcessEnvironment(ConfigurableEnvironment environment,
SpringApplication application) { SpringApplication application) {
File home = getHomeFolder(); File home = getHomeFolder();
File propertyFile = (home == null ? null : new File(home, FILE_NAME)); File propertyFile = (home != null ? new File(home, FILE_NAME) : null);
if (propertyFile != null && propertyFile.exists() && propertyFile.isFile()) { if (propertyFile != null && propertyFile.exists() && propertyFile.isFile()) {
FileSystemResource resource = new FileSystemResource(propertyFile); FileSystemResource resource = new FileSystemResource(propertyFile);
Properties properties; Properties properties;
......
...@@ -133,7 +133,7 @@ public class ClassPathChangeUploader ...@@ -133,7 +133,7 @@ public class ClassPathChangeUploader
private void logUpload(ClassLoaderFiles classLoaderFiles) { private void logUpload(ClassLoaderFiles classLoaderFiles) {
int size = classLoaderFiles.size(); int size = classLoaderFiles.size();
logger.info( logger.info(
"Uploaded " + size + " class " + (size == 1 ? "resource" : "resources")); "Uploaded " + size + " class " + (size != 1 ? "resources" : "resource"));
} }
private byte[] serialize(ClassLoaderFiles classLoaderFiles) throws IOException { private byte[] serialize(ClassLoaderFiles classLoaderFiles) throws IOException {
...@@ -160,10 +160,10 @@ public class ClassPathChangeUploader ...@@ -160,10 +160,10 @@ public class ClassPathChangeUploader
private ClassLoaderFile asClassLoaderFile(ChangedFile changedFile) private ClassLoaderFile asClassLoaderFile(ChangedFile changedFile)
throws IOException { throws IOException {
ClassLoaderFile.Kind kind = TYPE_MAPPINGS.get(changedFile.getType()); ClassLoaderFile.Kind kind = TYPE_MAPPINGS.get(changedFile.getType());
byte[] bytes = (kind == Kind.DELETED ? null byte[] bytes = (kind != Kind.DELETED
: FileCopyUtils.copyToByteArray(changedFile.getFile())); ? FileCopyUtils.copyToByteArray(changedFile.getFile()) : null);
long lastModified = (kind == Kind.DELETED ? System.currentTimeMillis() long lastModified = (kind != Kind.DELETED ? changedFile.getFile().lastModified()
: changedFile.getFile().lastModified()); : System.currentTimeMillis());
return new ClassLoaderFile(kind, lastModified, bytes); return new ClassLoaderFile(kind, lastModified, bytes);
} }
......
...@@ -55,7 +55,7 @@ public class ClassLoaderFile implements Serializable { ...@@ -55,7 +55,7 @@ public class ClassLoaderFile implements Serializable {
*/ */
public ClassLoaderFile(Kind kind, long lastModified, byte[] contents) { public ClassLoaderFile(Kind kind, long lastModified, byte[] contents) {
Assert.notNull(kind, "Kind must not be null"); Assert.notNull(kind, "Kind must not be null");
Assert.isTrue(kind == Kind.DELETED ? contents == null : contents != null, Assert.isTrue(kind != Kind.DELETED ? contents != null : contents == null,
() -> "Contents must " + (kind == Kind.DELETED ? "" : "not ") () -> "Contents must " + (kind == Kind.DELETED ? "" : "not ")
+ "be null"); + "be null");
this.kind = kind; this.kind = kind;
......
...@@ -88,8 +88,8 @@ public class HttpTunnelConnection implements TunnelConnection { ...@@ -88,8 +88,8 @@ public class HttpTunnelConnection implements TunnelConnection {
throw new IllegalArgumentException("Malformed URL '" + url + "'"); throw new IllegalArgumentException("Malformed URL '" + url + "'");
} }
this.requestFactory = requestFactory; this.requestFactory = requestFactory;
this.executor = (executor == null this.executor = (executor != null ? executor
? Executors.newCachedThreadPool(new TunnelThreadFactory()) : executor); : Executors.newCachedThreadPool(new TunnelThreadFactory()));
} }
@Override @Override
......
...@@ -139,7 +139,7 @@ public class ClassPathChangeUploaderTests { ...@@ -139,7 +139,7 @@ public class ClassPathChangeUploaderTests {
private void assertClassFile(ClassLoaderFile file, String content, Kind kind) { private void assertClassFile(ClassLoaderFile file, String content, Kind kind) {
assertThat(file.getContents()) assertThat(file.getContents())
.isEqualTo(content == null ? null : content.getBytes()); .isEqualTo(content != null ? content.getBytes() : null);
assertThat(file.getKind()).isEqualTo(kind); assertThat(file.getKind()).isEqualTo(kind);
} }
......
...@@ -45,8 +45,8 @@ public class SpockTestRestTemplateExample { ...@@ -45,8 +45,8 @@ public class SpockTestRestTemplateExample {
ObjectProvider<RestTemplateBuilder> builderProvider, ObjectProvider<RestTemplateBuilder> builderProvider,
Environment environment) { Environment environment) {
RestTemplateBuilder builder = builderProvider.getIfAvailable(); RestTemplateBuilder builder = builderProvider.getIfAvailable();
TestRestTemplate template = builder == null ? new TestRestTemplate() TestRestTemplate template = (builder != null ? new TestRestTemplate(builder)
: new TestRestTemplate(builder); : new TestRestTemplate());
template.setUriTemplateHandler(new LocalHostUriTemplateHandler(environment)); template.setUriTemplateHandler(new LocalHostUriTemplateHandler(environment));
return template; return template;
} }
......
...@@ -31,6 +31,7 @@ import org.springframework.test.context.junit4.SpringRunner; ...@@ -31,6 +31,7 @@ import org.springframework.test.context.junit4.SpringRunner;
* *
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
@SuppressWarnings("unused")
// tag::test[] // tag::test[]
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(properties = "spring.jmx.enabled=true") @SpringBootTest(properties = "spring.jmx.enabled=true")
...@@ -43,7 +44,6 @@ public class SampleJmxTests { ...@@ -43,7 +44,6 @@ public class SampleJmxTests {
@Test @Test
public void exampleTest() { public void exampleTest() {
// ... // ...
} }
} }
......
...@@ -105,8 +105,8 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?> ...@@ -105,8 +105,8 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
} }
Annotation mergedAnnotation = AnnotatedElementUtils.getMergedAnnotation(source, Annotation mergedAnnotation = AnnotatedElementUtils.getMergedAnnotation(source,
annotationType); annotationType);
return mergedAnnotation != null ? mergedAnnotation return (mergedAnnotation != null ? mergedAnnotation
: findMergedAnnotation(source.getSuperclass(), annotationType); : findMergedAnnotation(source.getSuperclass(), annotationType));
} }
private void collectProperties(Annotation annotation, Method attribute, private void collectProperties(Annotation annotation, Method attribute,
...@@ -143,8 +143,8 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?> ...@@ -143,8 +143,8 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
private String getName(PropertyMapping typeMapping, PropertyMapping attributeMapping, private String getName(PropertyMapping typeMapping, PropertyMapping attributeMapping,
Method attribute) { Method attribute) {
String prefix = (typeMapping == null ? "" : typeMapping.value()); String prefix = (typeMapping != null ? typeMapping.value() : "");
String name = (attributeMapping == null ? "" : attributeMapping.value()); String name = (attributeMapping != null ? attributeMapping.value() : "");
if (!StringUtils.hasText(name)) { if (!StringUtils.hasText(name)) {
name = toKebabCase(attribute.getName()); name = toKebabCase(attribute.getName());
} }
......
...@@ -115,10 +115,10 @@ class PropertyMappingContextCustomizer implements ContextCustomizer { ...@@ -115,10 +115,10 @@ class PropertyMappingContextCustomizer implements ContextCustomizer {
private String getAnnotationsDescription(Set<Class<?>> annotations) { private String getAnnotationsDescription(Set<Class<?>> annotations) {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
for (Class<?> annotation : annotations) { for (Class<?> annotation : annotations) {
result.append(result.length() == 0 ? "" : ", "); result.append(result.length() != 0 ? ", " : "");
result.append("@" + ClassUtils.getShortName(annotation)); result.append("@" + ClassUtils.getShortName(annotation));
} }
result.insert(0, annotations.size() == 1 ? "annotation " : "annotations "); result.insert(0, annotations.size() != 1 ? "annotations " : "annotation ");
return result.toString(); return result.toString();
} }
......
...@@ -168,10 +168,10 @@ class ImportsContextCustomizer implements ContextCustomizer { ...@@ -168,10 +168,10 @@ class ImportsContextCustomizer implements ContextCustomizer {
public String[] selectImports(AnnotationMetadata importingClassMetadata) { public String[] selectImports(AnnotationMetadata importingClassMetadata) {
BeanDefinition definition = this.beanFactory BeanDefinition definition = this.beanFactory
.getBeanDefinition(ImportsConfiguration.BEAN_NAME); .getBeanDefinition(ImportsConfiguration.BEAN_NAME);
Object testClass = (definition == null ? null Object testClass = (definition != null
: definition.getAttribute(TEST_CLASS_ATTRIBUTE)); ? definition.getAttribute(TEST_CLASS_ATTRIBUTE) : null);
return (testClass == null ? NO_IMPORTS return (testClass != null ? new String[] { ((Class<?>) testClass).getName() }
: new String[] { ((Class<?>) testClass).getName() }); : NO_IMPORTS);
} }
} }
......
...@@ -79,7 +79,7 @@ final class SpringBootConfigurationFinder { ...@@ -79,7 +79,7 @@ final class SpringBootConfigurationFinder {
private String getParentPackage(String sourcePackage) { private String getParentPackage(String sourcePackage) {
int lastDot = sourcePackage.lastIndexOf('.'); int lastDot = sourcePackage.lastIndexOf('.');
return (lastDot == -1 ? "" : sourcePackage.substring(0, lastDot)); return (lastDot != -1 ? sourcePackage.substring(0, lastDot) : "");
} }
/** /**
......
...@@ -44,6 +44,7 @@ import org.springframework.core.annotation.Order; ...@@ -44,6 +44,7 @@ import org.springframework.core.annotation.Order;
import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.StandardEnvironment; import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.ResourceLoader;
import org.springframework.test.context.ContextConfigurationAttributes; import org.springframework.test.context.ContextConfigurationAttributes;
import org.springframework.test.context.ContextCustomizer; import org.springframework.test.context.ContextCustomizer;
import org.springframework.test.context.ContextLoader; import org.springframework.test.context.ContextLoader;
...@@ -109,11 +110,11 @@ public class SpringBootContextLoader extends AbstractContextLoader { ...@@ -109,11 +110,11 @@ public class SpringBootContextLoader extends AbstractContextLoader {
if (!ObjectUtils.isEmpty(config.getActiveProfiles())) { if (!ObjectUtils.isEmpty(config.getActiveProfiles())) {
setActiveProfiles(environment, config.getActiveProfiles()); setActiveProfiles(environment, config.getActiveProfiles());
} }
ResourceLoader resourceLoader = (application.getResourceLoader() != null
? application.getResourceLoader()
: new DefaultResourceLoader(getClass().getClassLoader()));
TestPropertySourceUtils.addPropertiesFilesToEnvironment(environment, TestPropertySourceUtils.addPropertiesFilesToEnvironment(environment,
application.getResourceLoader() == null resourceLoader, config.getPropertySourceLocations());
? new DefaultResourceLoader(getClass().getClassLoader())
: application.getResourceLoader(),
config.getPropertySourceLocations());
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment, TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment,
getInlinedProperties(config)); getInlinedProperties(config));
application.setEnvironment(environment); application.setEnvironment(environment);
......
...@@ -164,8 +164,8 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr ...@@ -164,8 +164,8 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
WebAppConfiguration webAppConfiguration = AnnotatedElementUtils WebAppConfiguration webAppConfiguration = AnnotatedElementUtils
.findMergedAnnotation(mergedConfig.getTestClass(), .findMergedAnnotation(mergedConfig.getTestClass(),
WebAppConfiguration.class); WebAppConfiguration.class);
String resourceBasePath = (webAppConfiguration == null ? "src/main/webapp" String resourceBasePath = (webAppConfiguration != null
: webAppConfiguration.value()); ? webAppConfiguration.value() : "src/main/webapp");
mergedConfig = new WebMergedContextConfiguration(mergedConfig, mergedConfig = new WebMergedContextConfiguration(mergedConfig,
resourceBasePath); resourceBasePath);
} }
...@@ -313,17 +313,17 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr ...@@ -313,17 +313,17 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
*/ */
protected WebEnvironment getWebEnvironment(Class<?> testClass) { protected WebEnvironment getWebEnvironment(Class<?> testClass) {
SpringBootTest annotation = getAnnotation(testClass); SpringBootTest annotation = getAnnotation(testClass);
return (annotation == null ? null : annotation.webEnvironment()); return (annotation != null ? annotation.webEnvironment() : null);
} }
protected Class<?>[] getClasses(Class<?> testClass) { protected Class<?>[] getClasses(Class<?> testClass) {
SpringBootTest annotation = getAnnotation(testClass); SpringBootTest annotation = getAnnotation(testClass);
return (annotation == null ? null : annotation.classes()); return (annotation != null ? annotation.classes() : null);
} }
protected String[] getProperties(Class<?> testClass) { protected String[] getProperties(Class<?> testClass) {
SpringBootTest annotation = getAnnotation(testClass); SpringBootTest annotation = getAnnotation(testClass);
return (annotation == null ? null : annotation.properties()); return (annotation != null ? annotation.properties() : null);
} }
protected SpringBootTest getAnnotation(Class<?> testClass) { protected SpringBootTest getAnnotation(Class<?> testClass) {
......
...@@ -75,7 +75,7 @@ public final class JsonContent<T> implements AssertProvider<JsonContentAssert> { ...@@ -75,7 +75,7 @@ public final class JsonContent<T> implements AssertProvider<JsonContentAssert> {
@Override @Override
public String toString() { public String toString() {
return "JsonContent " + this.json return "JsonContent " + this.json
+ (this.type == null ? "" : " created from " + this.type); + (this.type != null ? " created from " + this.type : "");
} }
} }
...@@ -991,7 +991,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq ...@@ -991,7 +991,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
} }
try { try {
return JSONCompare.compareJSON( return JSONCompare.compareJSON(
(expectedJson == null ? null : expectedJson.toString()), (expectedJson != null ? expectedJson.toString() : null),
this.actual.toString(), compareMode); this.actual.toString(), compareMode);
} }
catch (Exception ex) { catch (Exception ex) {
...@@ -1009,7 +1009,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq ...@@ -1009,7 +1009,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
} }
try { try {
return JSONCompare.compareJSON( return JSONCompare.compareJSON(
(expectedJson == null ? null : expectedJson.toString()), (expectedJson != null ? expectedJson.toString() : null),
this.actual.toString(), comparator); this.actual.toString(), comparator);
} }
catch (Exception ex) { catch (Exception ex) {
...@@ -1054,7 +1054,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq ...@@ -1054,7 +1054,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
JsonPathValue(CharSequence expression, Object... args) { JsonPathValue(CharSequence expression, Object... args) {
org.springframework.util.Assert.hasText( org.springframework.util.Assert.hasText(
(expression == null ? null : expression.toString()), (expression != null ? expression.toString() : null),
"expression must not be null or empty"); "expression must not be null or empty");
this.expression = String.format(expression.toString(), args); this.expression = String.format(expression.toString(), args);
this.jsonPath = JsonPath.compile(this.expression); this.jsonPath = JsonPath.compile(this.expression);
...@@ -1107,7 +1107,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq ...@@ -1107,7 +1107,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
public Object getValue(boolean required) { public Object getValue(boolean required) {
try { try {
CharSequence json = JsonContentAssert.this.actual; CharSequence json = JsonContentAssert.this.actual;
return this.jsonPath.read(json == null ? null : json.toString()); return this.jsonPath.read(json != null ? json.toString() : null);
} }
catch (Exception ex) { catch (Exception ex) {
if (!required) { if (!required) {
......
...@@ -43,7 +43,7 @@ class JsonLoader { ...@@ -43,7 +43,7 @@ class JsonLoader {
JsonLoader(Class<?> resourceLoadClass, Charset charset) { JsonLoader(Class<?> resourceLoadClass, Charset charset) {
this.resourceLoadClass = resourceLoadClass; this.resourceLoadClass = resourceLoadClass;
this.charset = charset == null ? StandardCharsets.UTF_8 : charset; this.charset = (charset != null ? charset : StandardCharsets.UTF_8);
} }
Class<?> getResourceLoadClass() { Class<?> getResourceLoadClass() {
......
...@@ -63,7 +63,7 @@ public final class ObjectContent<T> implements AssertProvider<ObjectContentAsser ...@@ -63,7 +63,7 @@ public final class ObjectContent<T> implements AssertProvider<ObjectContentAsser
@Override @Override
public String toString() { public String toString() {
return "ObjectContent " + this.object return "ObjectContent " + this.object
+ (this.type == null ? "" : " created from " + this.type); + (this.type != null ? " created from " + this.type : "");
} }
} }
...@@ -186,7 +186,7 @@ class JsonReader { ...@@ -186,7 +186,7 @@ class JsonReader {
try { try {
return Deprecation.Level.valueOf(value.toUpperCase(Locale.ENGLISH)); return Deprecation.Level.valueOf(value.toUpperCase(Locale.ENGLISH));
} }
catch (IllegalArgumentException e) { catch (IllegalArgumentException ex) {
// let's use the default // let's use the default
} }
} }
......
...@@ -50,7 +50,7 @@ public abstract class AbstractConfigurationMetadataTests { ...@@ -50,7 +50,7 @@ public abstract class AbstractConfigurationMetadataTests {
assertThat(actual).isNotNull(); assertThat(actual).isNotNull();
assertThat(actual.getId()).isEqualTo(id); assertThat(actual.getId()).isEqualTo(id);
assertThat(actual.getName()).isEqualTo(name); assertThat(actual.getName()).isEqualTo(name);
String typeName = type != null ? type.getName() : null; String typeName = (type != null ? type.getName() : null);
assertThat(actual.getType()).isEqualTo(typeName); assertThat(actual.getType()).isEqualTo(typeName);
assertThat(actual.getDefaultValue()).isEqualTo(defaultValue); assertThat(actual.getDefaultValue()).isEqualTo(defaultValue);
} }
......
...@@ -390,7 +390,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor ...@@ -390,7 +390,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
this.metadataCollector.add(ItemMetadata.newGroup(nestedPrefix, this.metadataCollector.add(ItemMetadata.newGroup(nestedPrefix,
this.typeUtils.getQualifiedName(returnElement), this.typeUtils.getQualifiedName(returnElement),
this.typeUtils.getQualifiedName(element), this.typeUtils.getQualifiedName(element),
(getter == null ? null : getter.toString()))); (getter != null ? getter.toString() : null)));
processTypeElement(nestedPrefix, (TypeElement) returnElement, source); processTypeElement(nestedPrefix, (TypeElement) returnElement, source);
} }
} }
......
...@@ -156,8 +156,8 @@ class TypeElementMembers { ...@@ -156,8 +156,8 @@ class TypeElementMembers {
} }
private String getAccessorName(String methodName) { private String getAccessorName(String methodName) {
String name = methodName.startsWith("is") ? methodName.substring(2) String name = (methodName.startsWith("is") ? methodName.substring(2)
: methodName.substring(3); : methodName.substring(3));
name = Character.toLowerCase(name.charAt(0)) + name.substring(1); name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
return name; return name;
} }
......
...@@ -139,8 +139,8 @@ class TypeUtils { ...@@ -139,8 +139,8 @@ class TypeUtils {
} }
public String getJavaDoc(Element element) { public String getJavaDoc(Element element) {
String javadoc = (element == null ? null String javadoc = (element != null
: this.env.getElementUtils().getDocComment(element)); ? this.env.getElementUtils().getDocComment(element) : null);
if (javadoc != null) { if (javadoc != null) {
javadoc = javadoc.trim(); javadoc = javadoc.trim();
} }
......
...@@ -35,7 +35,7 @@ final class Trees extends ReflectionWrapper { ...@@ -35,7 +35,7 @@ final class Trees extends ReflectionWrapper {
public Tree getTree(Element element) throws Exception { public Tree getTree(Element element) throws Exception {
Object tree = findMethod("getTree", Element.class).invoke(getInstance(), element); Object tree = findMethod("getTree", Element.class).invoke(getInstance(), element);
return (tree == null ? null : new Tree(tree)); return (tree != null ? new Tree(tree) : null);
} }
public static Trees instance(ProcessingEnvironment env) throws Exception { public static Trees instance(ProcessingEnvironment env) throws Exception {
......
...@@ -43,7 +43,7 @@ class VariableTree extends ReflectionWrapper { ...@@ -43,7 +43,7 @@ class VariableTree extends ReflectionWrapper {
public ExpressionTree getInitializer() throws Exception { public ExpressionTree getInitializer() throws Exception {
Object instance = findMethod("getInitializer").invoke(getInstance()); Object instance = findMethod("getInitializer").invoke(getInstance());
return (instance == null ? null : new ExpressionTree(instance)); return (instance != null ? new ExpressionTree(instance) : null);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
......
...@@ -178,7 +178,7 @@ public class ConfigurationMetadata { ...@@ -178,7 +178,7 @@ public class ConfigurationMetadata {
} }
public static String nestedPrefix(String prefix, String name) { public static String nestedPrefix(String prefix, String name) {
String nestedPrefix = (prefix == null ? "" : prefix); String nestedPrefix = (prefix != null ? prefix : "");
String dashedName = toDashedCase(name); String dashedName = toDashedCase(name);
nestedPrefix += ("".equals(nestedPrefix) ? dashedName : "." + dashedName); nestedPrefix += ("".equals(nestedPrefix) ? dashedName : "." + dashedName);
return nestedPrefix; return nestedPrefix;
......
...@@ -108,7 +108,7 @@ public class ItemDeprecation { ...@@ -108,7 +108,7 @@ public class ItemDeprecation {
} }
private int nullSafeHashCode(Object o) { private int nullSafeHashCode(Object o) {
return (o == null ? 0 : o.hashCode()); return (o != null ? o.hashCode() : 0);
} }
} }
...@@ -61,11 +61,11 @@ public final class ItemMetadata implements Comparable<ItemMetadata> { ...@@ -61,11 +61,11 @@ public final class ItemMetadata implements Comparable<ItemMetadata> {
while (prefix != null && prefix.endsWith(".")) { while (prefix != null && prefix.endsWith(".")) {
prefix = prefix.substring(0, prefix.length() - 1); prefix = prefix.substring(0, prefix.length() - 1);
} }
StringBuilder fullName = new StringBuilder(prefix == null ? "" : prefix); StringBuilder fullName = new StringBuilder(prefix != null ? prefix : "");
if (fullName.length() > 0 && name != null) { if (fullName.length() > 0 && name != null) {
fullName.append("."); fullName.append(".");
} }
fullName.append(name == null ? "" : ConfigurationMetadata.toDashedCase(name)); fullName.append(name != null ? ConfigurationMetadata.toDashedCase(name) : "");
return fullName.toString(); return fullName.toString();
} }
...@@ -196,7 +196,7 @@ public final class ItemMetadata implements Comparable<ItemMetadata> { ...@@ -196,7 +196,7 @@ public final class ItemMetadata implements Comparable<ItemMetadata> {
} }
private int nullSafeHashCode(Object o) { private int nullSafeHashCode(Object o) {
return (o == null ? 0 : o.hashCode()); return (o != null ? o.hashCode() : 0);
} }
@Override @Override
......
...@@ -98,8 +98,8 @@ public class TestConfigurationMetadataAnnotationProcessor ...@@ -98,8 +98,8 @@ public class TestConfigurationMetadataAnnotationProcessor
} }
return this.metadata; return this.metadata;
} }
catch (IOException e) { catch (IOException ex) {
throw new RuntimeException("Failed to read metadata from disk", e); throw new RuntimeException("Failed to read metadata from disk", ex);
} }
} }
......
...@@ -109,8 +109,8 @@ public class DefaultLaunchScript implements LaunchScript { ...@@ -109,8 +109,8 @@ public class DefaultLaunchScript implements LaunchScript {
} }
} }
else { else {
value = (defaultValue == null ? matcher.group(0) value = (defaultValue != null ? defaultValue.substring(1)
: defaultValue.substring(1)); : matcher.group(0));
} }
matcher.appendReplacement(expanded, value.replace("$", "\\$")); matcher.appendReplacement(expanded, value.replace("$", "\\$"));
} }
......
...@@ -356,7 +356,7 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable { ...@@ -356,7 +356,7 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable {
@Override @Override
public int read() throws IOException { public int read() throws IOException {
int read = (this.headerStream == null ? -1 : this.headerStream.read()); int read = (this.headerStream != null ? this.headerStream.read() : -1);
if (read != -1) { if (read != -1) {
this.headerStream = null; this.headerStream = null;
return read; return read;
...@@ -371,8 +371,8 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable { ...@@ -371,8 +371,8 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable {
@Override @Override
public int read(byte[] b, int off, int len) throws IOException { public int read(byte[] b, int off, int len) throws IOException {
int read = (this.headerStream == null ? -1 int read = (this.headerStream != null ? this.headerStream.read(b, off, len)
: this.headerStream.read(b, off, len)); : -1);
if (read != -1) { if (read != -1) {
this.headerStream = null; this.headerStream = null;
return read; return read;
......
...@@ -63,7 +63,7 @@ public class Library { ...@@ -63,7 +63,7 @@ public class Library {
* @param unpackRequired if the library needs to be unpacked before it can be used * @param unpackRequired if the library needs to be unpacked before it can be used
*/ */
public Library(String name, File file, LibraryScope scope, boolean unpackRequired) { public Library(String name, File file, LibraryScope scope, boolean unpackRequired) {
this.name = (name == null ? file.getName() : name); this.name = (name != null ? name : file.getName());
this.file = file; this.file = file;
this.scope = scope; this.scope = scope;
this.unpackRequired = unpackRequired; this.unpackRequired = unpackRequired;
......
...@@ -452,8 +452,8 @@ public abstract class MainClassFinder { ...@@ -452,8 +452,8 @@ public abstract class MainClassFinder {
"Unable to find a single main class from the following candidates " "Unable to find a single main class from the following candidates "
+ matchingMainClasses); + matchingMainClasses);
} }
return matchingMainClasses.isEmpty() ? null return (matchingMainClasses.isEmpty() ? null
: matchingMainClasses.iterator().next().getName(); : matchingMainClasses.iterator().next().getName());
} }
} }
......
...@@ -116,8 +116,8 @@ public abstract class Launcher { ...@@ -116,8 +116,8 @@ public abstract class Launcher {
protected final Archive createArchive() throws Exception { protected final Archive createArchive() throws Exception {
ProtectionDomain protectionDomain = getClass().getProtectionDomain(); ProtectionDomain protectionDomain = getClass().getProtectionDomain();
CodeSource codeSource = protectionDomain.getCodeSource(); CodeSource codeSource = protectionDomain.getCodeSource();
URI location = (codeSource == null ? null : codeSource.getLocation().toURI()); URI location = (codeSource != null ? codeSource.getLocation().toURI() : null);
String path = (location == null ? null : location.getSchemeSpecificPart()); String path = (location != null ? location.getSchemeSpecificPart() : null);
if (path == null) { if (path == null) {
throw new IllegalStateException("Unable to determine code source archive"); throw new IllegalStateException("Unable to determine code source archive");
} }
......
...@@ -38,7 +38,7 @@ public class MainMethodRunner { ...@@ -38,7 +38,7 @@ public class MainMethodRunner {
*/ */
public MainMethodRunner(String mainClass, String[] args) { public MainMethodRunner(String mainClass, String[] args) {
this.mainClassName = mainClass; this.mainClassName = mainClass;
this.args = (args == null ? null : args.clone()); this.args = (args != null ? args.clone() : null);
} }
public void run() throws Exception { public void run() throws Exception {
......
...@@ -434,8 +434,9 @@ public class PropertiesLauncher extends Launcher { ...@@ -434,8 +434,9 @@ public class PropertiesLauncher extends Launcher {
return SystemPropertyUtils.resolvePlaceholders(this.properties, value); return SystemPropertyUtils.resolvePlaceholders(this.properties, value);
} }
} }
return defaultValue == null ? defaultValue return (defaultValue != null
: SystemPropertyUtils.resolvePlaceholders(this.properties, defaultValue); ? SystemPropertyUtils.resolvePlaceholders(this.properties, defaultValue)
: defaultValue);
} }
@Override @Override
......
...@@ -127,8 +127,7 @@ public class RandomAccessDataFile implements RandomAccessData { ...@@ -127,8 +127,7 @@ public class RandomAccessDataFile implements RandomAccessData {
} }
/** /**
* {@link InputStream} implementation for the * {@link InputStream} implementation for the {@link RandomAccessDataFile}.
* {@link RandomAccessDataFile}.
*/ */
private class DataInputStream extends InputStream { private class DataInputStream extends InputStream {
...@@ -145,7 +144,7 @@ public class RandomAccessDataFile implements RandomAccessData { ...@@ -145,7 +144,7 @@ public class RandomAccessDataFile implements RandomAccessData {
@Override @Override
public int read(byte[] b) throws IOException { public int read(byte[] b) throws IOException {
return read(b, 0, b == null ? 0 : b.length); return read(b, 0, b != null ? b.length : 0);
} }
@Override @Override
......
...@@ -250,7 +250,7 @@ public class Handler extends URLStreamHandler { ...@@ -250,7 +250,7 @@ public class Handler extends URLStreamHandler {
} }
private int hashCode(String protocol, String file) { private int hashCode(String protocol, String file) {
int result = (protocol == null ? 0 : protocol.hashCode()); int result = (protocol != null ? protocol.hashCode() : 0);
int separatorIndex = file.indexOf(SEPARATOR); int separatorIndex = file.indexOf(SEPARATOR);
if (separatorIndex == -1) { if (separatorIndex == -1) {
return result + file.hashCode(); return result + file.hashCode();
...@@ -319,7 +319,7 @@ public class Handler extends URLStreamHandler { ...@@ -319,7 +319,7 @@ public class Handler extends URLStreamHandler {
String path = name.substring(FILE_PROTOCOL.length()); String path = name.substring(FILE_PROTOCOL.length());
File file = new File(URLDecoder.decode(path, "UTF-8")); File file = new File(URLDecoder.decode(path, "UTF-8"));
Map<File, JarFile> cache = rootFileCache.get(); Map<File, JarFile> cache = rootFileCache.get();
JarFile result = (cache == null ? null : cache.get(file)); JarFile result = (cache != null ? cache.get(file) : null);
if (result == null) { if (result == null) {
result = new JarFile(file); result = new JarFile(file);
addToRootFileCache(file, result); addToRootFileCache(file, result);
......
...@@ -77,7 +77,7 @@ class JarEntry extends java.util.jar.JarEntry implements FileHeader { ...@@ -77,7 +77,7 @@ class JarEntry extends java.util.jar.JarEntry implements FileHeader {
@Override @Override
public Attributes getAttributes() throws IOException { public Attributes getAttributes() throws IOException {
Manifest manifest = this.jarFile.getManifest(); Manifest manifest = this.jarFile.getManifest();
return (manifest == null ? null : manifest.getAttributes(getName())); return (manifest != null ? manifest.getAttributes(getName()) : null);
} }
@Override @Override
......
...@@ -168,7 +168,7 @@ public class JarFile extends java.util.jar.JarFile { ...@@ -168,7 +168,7 @@ public class JarFile extends java.util.jar.JarFile {
@Override @Override
public Manifest getManifest() throws IOException { public Manifest getManifest() throws IOException {
Manifest manifest = (this.manifest == null ? null : this.manifest.get()); Manifest manifest = (this.manifest != null ? this.manifest.get() : null);
if (manifest == null) { if (manifest == null) {
try { try {
manifest = this.manifestSupplier.get(); manifest = this.manifestSupplier.get();
...@@ -222,7 +222,7 @@ public class JarFile extends java.util.jar.JarFile { ...@@ -222,7 +222,7 @@ public class JarFile extends java.util.jar.JarFile {
if (ze instanceof JarEntry) { if (ze instanceof JarEntry) {
return this.entries.getInputStream((JarEntry) ze); return this.entries.getInputStream((JarEntry) ze);
} }
return getInputStream(ze == null ? null : ze.getName()); return getInputStream(ze != null ? ze.getName() : null);
} }
InputStream getInputStream(String name) throws IOException { InputStream getInputStream(String name) throws IOException {
......
...@@ -277,7 +277,7 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable<JarEntry> { ...@@ -277,7 +277,7 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable<JarEntry> {
} }
private AsciiBytes applyFilter(AsciiBytes name) { private AsciiBytes applyFilter(AsciiBytes name) {
return (this.filter == null ? name : this.filter.apply(name)); return (this.filter != null ? this.filter.apply(name) : name);
} }
/** /**
......
...@@ -204,7 +204,7 @@ final class JarURLConnection extends java.net.JarURLConnection { ...@@ -204,7 +204,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
return this.jarFile.size(); return this.jarFile.size();
} }
JarEntry entry = getJarEntry(); JarEntry entry = getJarEntry();
return (entry == null ? -1 : (int) entry.getSize()); return (entry != null ? (int) entry.getSize() : -1);
} }
catch (IOException ex) { catch (IOException ex) {
return -1; return -1;
...@@ -219,7 +219,7 @@ final class JarURLConnection extends java.net.JarURLConnection { ...@@ -219,7 +219,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
@Override @Override
public String getContentType() { public String getContentType() {
return (this.jarEntryName == null ? null : this.jarEntryName.getContentType()); return (this.jarEntryName != null ? this.jarEntryName.getContentType() : null);
} }
@Override @Override
...@@ -241,7 +241,7 @@ final class JarURLConnection extends java.net.JarURLConnection { ...@@ -241,7 +241,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
} }
try { try {
JarEntry entry = getJarEntry(); JarEntry entry = getJarEntry();
return (entry == null ? 0 : entry.getTime()); return (entry != null ? entry.getTime() : 0);
} }
catch (IOException ex) { catch (IOException ex) {
return 0; return 0;
......
...@@ -155,7 +155,7 @@ public abstract class SystemPropertyUtils { ...@@ -155,7 +155,7 @@ public abstract class SystemPropertyUtils {
if (propVal != null) { if (propVal != null) {
return propVal; return propVal;
} }
return properties == null ? null : properties.getProperty(placeholderName); return (properties != null ? properties.getProperty(placeholderName) : null);
} }
public static String getProperty(String key) { public static String getProperty(String key) {
......
...@@ -69,9 +69,9 @@ public class ExplodedArchiveTests { ...@@ -69,9 +69,9 @@ public class ExplodedArchiveTests {
File file = this.temporaryFolder.newFile(); File file = this.temporaryFolder.newFile();
TestJarCreator.createTestJar(file); TestJarCreator.createTestJar(file);
this.rootFolder = StringUtils.hasText(folderName) this.rootFolder = (StringUtils.hasText(folderName)
? this.temporaryFolder.newFolder(folderName) ? this.temporaryFolder.newFolder(folderName)
: this.temporaryFolder.newFolder(); : this.temporaryFolder.newFolder());
JarFile jarFile = new JarFile(file); JarFile jarFile = new JarFile(file);
Enumeration<JarEntry> entries = jarFile.entries(); Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) { while (entries.hasMoreElements()) {
......
...@@ -456,8 +456,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { ...@@ -456,8 +456,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
private void addDependencies(List<URL> urls) private void addDependencies(List<URL> urls)
throws MalformedURLException, MojoExecutionException { throws MalformedURLException, MojoExecutionException {
FilterArtifacts filters = this.useTestClasspath ? getFilters() FilterArtifacts filters = (this.useTestClasspath ? getFilters()
: getFilters(new TestArtifactFilter()); : getFilters(new TestArtifactFilter()));
Set<Artifact> artifacts = filterDependencies(this.project.getArtifacts(), Set<Artifact> artifacts = filterDependencies(this.project.getArtifacts(),
filters); filters);
for (Artifact artifact : artifacts) { for (Artifact artifact : artifacts) {
...@@ -505,7 +505,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { ...@@ -505,7 +505,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
public void uncaughtException(Thread thread, Throwable ex) { public void uncaughtException(Thread thread, Throwable ex) {
if (!(ex instanceof ThreadDeath)) { if (!(ex instanceof ThreadDeath)) {
synchronized (this.monitor) { synchronized (this.monitor) {
this.exception = (this.exception == null ? ex : this.exception); this.exception = (this.exception != null ? this.exception : ex);
} }
getLog().warn(ex); getLog().warn(ex);
} }
......
...@@ -144,8 +144,8 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { ...@@ -144,8 +144,8 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
/** /**
* A list of the libraries that must be unpacked from fat jars in order to run. * A list of the libraries that must be unpacked from fat jars in order to run.
* Specify each library as a {@code <dependency>} with a {@code <groupId>} and * Specify each library as a {@code <dependency>} with a {@code <groupId>} and a
* a {@code <artifactId>} and they will be unpacked at runtime. * {@code <artifactId>} and they will be unpacked at runtime.
* @since 1.1 * @since 1.1
*/ */
@Parameter @Parameter
...@@ -156,10 +156,10 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { ...@@ -156,10 +156,10 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
* jar. * jar.
* <p> * <p>
* Currently, some tools do not accept this format so you may not always be able to * Currently, some tools do not accept this format so you may not always be able to
* use this technique. For example, {@code jar -xf} may silently fail to extract * use this technique. For example, {@code jar -xf} may silently fail to extract a jar
* a jar or war that has been made fully-executable. It is recommended that you only * or war that has been made fully-executable. It is recommended that you only enable
* enable this option if you intend to execute it directly, rather than running it * this option if you intend to execute it directly, rather than running it with
* with {@code java -jar} or deploying it to a servlet container. * {@code java -jar} or deploying it to a servlet container.
* @since 1.3 * @since 1.3
*/ */
@Parameter(defaultValue = "false") @Parameter(defaultValue = "false")
...@@ -226,7 +226,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { ...@@ -226,7 +226,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
} }
private File getTargetFile() { private File getTargetFile() {
String classifier = (this.classifier == null ? "" : this.classifier.trim()); String classifier = (this.classifier != null ? this.classifier.trim() : "");
if (!classifier.isEmpty() && !classifier.startsWith("-")) { if (!classifier.isEmpty() && !classifier.startsWith("-")) {
classifier = "-" + classifier; classifier = "-" + classifier;
} }
...@@ -287,7 +287,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { ...@@ -287,7 +287,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
} }
private String removeLineBreaks(String description) { private String removeLineBreaks(String description) {
return (description == null ? null : description.replaceAll("\\s+", " ")); return (description != null ? description.replaceAll("\\s+", " ") : null);
} }
private void putIfMissing(Properties properties, String key, private void putIfMissing(Properties properties, String key,
......
...@@ -62,7 +62,7 @@ public class DefaultApplicationArguments implements ApplicationArguments { ...@@ -62,7 +62,7 @@ public class DefaultApplicationArguments implements ApplicationArguments {
@Override @Override
public List<String> getOptionValues(String name) { public List<String> getOptionValues(String name) {
List<String> values = this.source.getOptionValues(name); List<String> values = this.source.getOptionValues(name);
return (values == null ? null : Collections.unmodifiableList(values)); return (values != null ? Collections.unmodifiableList(values) : null);
} }
@Override @Override
......
...@@ -93,7 +93,7 @@ class ExitCodeGenerators implements Iterable<ExitCodeGenerator> { ...@@ -93,7 +93,7 @@ class ExitCodeGenerators implements Iterable<ExitCodeGenerator> {
} }
} }
catch (Exception ex) { catch (Exception ex) {
exitCode = (exitCode == 0 ? 1 : exitCode); exitCode = (exitCode != 0 ? exitCode : 1);
ex.printStackTrace(); ex.printStackTrace();
} }
} }
......
...@@ -107,8 +107,8 @@ public class ResourceBanner implements Banner { ...@@ -107,8 +107,8 @@ public class ResourceBanner implements Banner {
} }
protected String getApplicationVersion(Class<?> sourceClass) { protected String getApplicationVersion(Class<?> sourceClass) {
Package sourcePackage = (sourceClass == null ? null : sourceClass.getPackage()); Package sourcePackage = (sourceClass != null ? sourceClass.getPackage() : null);
return (sourcePackage == null ? null : sourcePackage.getImplementationVersion()); return (sourcePackage != null ? sourcePackage.getImplementationVersion() : null);
} }
protected String getBootVersion() { protected String getBootVersion() {
...@@ -132,14 +132,14 @@ public class ResourceBanner implements Banner { ...@@ -132,14 +132,14 @@ public class ResourceBanner implements Banner {
MutablePropertySources sources = new MutablePropertySources(); MutablePropertySources sources = new MutablePropertySources();
String applicationTitle = getApplicationTitle(sourceClass); String applicationTitle = getApplicationTitle(sourceClass);
Map<String, Object> titleMap = Collections.singletonMap("application.title", Map<String, Object> titleMap = Collections.singletonMap("application.title",
(applicationTitle == null ? "" : applicationTitle)); (applicationTitle != null ? applicationTitle : ""));
sources.addFirst(new MapPropertySource("title", titleMap)); sources.addFirst(new MapPropertySource("title", titleMap));
return new PropertySourcesPropertyResolver(sources); return new PropertySourcesPropertyResolver(sources);
} }
protected String getApplicationTitle(Class<?> sourceClass) { protected String getApplicationTitle(Class<?> sourceClass) {
Package sourcePackage = (sourceClass == null ? null : sourceClass.getPackage()); Package sourcePackage = (sourceClass != null ? sourceClass.getPackage() : null);
return (sourcePackage == null ? null : sourcePackage.getImplementationTitle()); return (sourcePackage != null ? sourcePackage.getImplementationTitle() : null);
} }
} }
...@@ -553,8 +553,8 @@ public class SpringApplication { ...@@ -553,8 +553,8 @@ public class SpringApplication {
if (this.bannerMode == Banner.Mode.OFF) { if (this.bannerMode == Banner.Mode.OFF) {
return null; return null;
} }
ResourceLoader resourceLoader = this.resourceLoader != null ? this.resourceLoader ResourceLoader resourceLoader = (this.resourceLoader != null ? this.resourceLoader
: new DefaultResourceLoader(getClassLoader()); : new DefaultResourceLoader(getClassLoader()));
SpringApplicationBannerPrinter bannerPrinter = new SpringApplicationBannerPrinter( SpringApplicationBannerPrinter bannerPrinter = new SpringApplicationBannerPrinter(
resourceLoader, this.banner); resourceLoader, this.banner);
if (this.bannerMode == Mode.LOG) { if (this.bannerMode == Mode.LOG) {
...@@ -1304,7 +1304,7 @@ public class SpringApplication { ...@@ -1304,7 +1304,7 @@ public class SpringApplication {
} }
catch (Exception ex) { catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
exitCode = (exitCode == 0 ? 1 : exitCode); exitCode = (exitCode != 0 ? exitCode : 1);
} }
return exitCode; return exitCode;
} }
......
...@@ -163,7 +163,7 @@ class SpringApplicationBannerPrinter { ...@@ -163,7 +163,7 @@ class SpringApplicationBannerPrinter {
@Override @Override
public void printBanner(Environment environment, Class<?> sourceClass, public void printBanner(Environment environment, Class<?> sourceClass,
PrintStream out) { PrintStream out) {
sourceClass = (sourceClass == null ? this.sourceClass : sourceClass); sourceClass = (sourceClass != null ? sourceClass : this.sourceClass);
this.banner.printBanner(environment, sourceClass, out); this.banner.printBanner(environment, sourceClass, out);
} }
......
...@@ -99,7 +99,7 @@ class SpringApplicationRunListeners { ...@@ -99,7 +99,7 @@ class SpringApplicationRunListeners {
} }
else { else {
String message = ex.getMessage(); String message = ex.getMessage();
message = (message == null ? "no error message" : message); message = (message != null ? message : "no error message");
this.log.warn("Error handling failed (" + message + ")"); this.log.warn("Error handling failed (" + message + ")");
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment