Merge branch '1.5.x' into 2.0.x

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

View File

@ -111,7 +111,7 @@ class CloudFoundrySecurityService {
return extractTokenKeys(this.restTemplate
.getForObject(getUaaUrl() + "/token_keys", Map.class));
}
catch (HttpStatusCodeException e) {
catch (HttpStatusCodeException ex) {
throw new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE,
"UAA not reachable");
}

View File

@ -175,8 +175,8 @@ public class ConditionsReportEndpoint {
public MessageAndConditions(ConditionAndOutcomes conditionAndOutcomes) {
for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) {
List<MessageAndCondition> target = conditionAndOutcome.getOutcome()
.isMatch() ? this.matched : this.notMatched;
List<MessageAndCondition> target = (conditionAndOutcome.getOutcome()
.isMatch() ? this.matched : this.notMatched);
target.add(new MessageAndCondition(conditionAndOutcome));
}
}

View File

@ -132,9 +132,9 @@ class ManagementContextConfigurationImportSelector
private int readOrder(AnnotationMetadata annotationMetadata) {
Map<String, Object> attributes = annotationMetadata
.getAnnotationAttributes(Order.class.getName());
Integer order = (attributes == null ? null
: (Integer) attributes.get("value"));
return (order == null ? Ordered.LOWEST_PRECEDENCE : order);
Integer order = (attributes != null ? (Integer) attributes.get("value")
: null);
return (order != null ? order : Ordered.LOWEST_PRECEDENCE);
}
public String getClassName() {

View File

@ -98,7 +98,7 @@ public class OrderedHealthAggregator extends AbstractHealthAggregator {
public int compare(Status s1, Status s2) {
int i1 = this.statusOrder.indexOf(s1.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())));
}
}

View File

@ -112,7 +112,7 @@ public class LoggersEndpoint {
}
private String getName(LogLevel level) {
return (level == null ? null : level.name());
return (level != null ? level.name() : null);
}
public String getConfiguredLevel() {

View File

@ -48,7 +48,7 @@ public class SolrHealthIndicator extends AbstractHealthIndicator {
request.setAction(CoreAdminParams.CoreAdminAction.STATUS);
CoreAdminResponse response = request.process(this.solrClient);
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);
}

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);
}
}

View File

@ -64,7 +64,7 @@ public class SpringApplicationWebApplicationInitializer
private Manifest getManifest(ServletContext servletContext) throws IOException {
InputStream stream = servletContext.getResourceAsStream("/META-INF/MANIFEST.MF");
return (stream == null ? null : new Manifest(stream));
return (stream != null ? new Manifest(stream) : null);
}
@Override

View File

@ -260,7 +260,7 @@ public class CommandRunner implements Iterable<Command> {
}
protected boolean errorMessage(String message) {
Log.error(message == null ? "Unexpected error" : message);
Log.error(message != null ? message : "Unexpected error");
return message != null;
}
@ -280,8 +280,8 @@ public class CommandRunner implements Iterable<Command> {
String usageHelp = command.getUsageHelp();
String description = command.getDescription();
Log.info(String.format("%n %1$s %2$-15s%n %3$s", command.getName(),
(usageHelp == null ? "" : usageHelp),
(description == null ? "" : description)));
(usageHelp != null ? usageHelp : ""),
(description != null ? description : "")));
}
}
Log.info("");

View File

@ -230,7 +230,7 @@ abstract class ArchiveCommand extends OptionParsingCommand {
private String commaDelimitedClassNames(Class<?>[] classes) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < classes.length; i++) {
builder.append(i == 0 ? "" : ",");
builder.append(i != 0 ? "," : "");
builder.append(classes[i].getName());
}
return builder.toString();

View File

@ -107,7 +107,7 @@ public class HelpCommand extends AbstractCommand {
}
Collection<HelpExample> examples = command.getExamples();
if (examples != null) {
Log.info(examples.size() == 1 ? "example:" : "examples:");
Log.info(examples.size() != 1 ? "examples:" : "example:");
Log.info("");
for (HelpExample example : examples) {
Log.info(" " + example.getDescription() + ":");

View File

@ -45,7 +45,7 @@ public class HintCommand extends AbstractCommand {
@Override
public ExitStatus run(String... args) throws Exception {
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);
for (int i = 2; i < args.length; i++) {
arguments.add(args[i]);

View File

@ -149,8 +149,8 @@ class InitializrServiceMetadata {
}
JSONObject type = root.getJSONObject(TYPE_EL);
JSONArray array = type.getJSONArray(VALUES_EL);
String defaultType = type.has(DEFAULT_ATTRIBUTE)
? type.getString(DEFAULT_ATTRIBUTE) : null;
String defaultType = (type.has(DEFAULT_ATTRIBUTE)
? type.getString(DEFAULT_ATTRIBUTE) : null);
for (int i = 0; i < array.length(); i++) {
JSONObject typeJson = array.getJSONObject(i);
ProjectType projectType = parseType(typeJson, defaultType);
@ -212,7 +212,7 @@ class InitializrServiceMetadata {
private String getStringValue(JSONObject object, String name, String defaultValue)
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 {

View File

@ -358,8 +358,8 @@ class ProjectGenerationRequest {
return builder.build();
}
catch (URISyntaxException e) {
throw new ReportableException("Invalid service URL (" + e.getMessage() + ")");
catch (URISyntaxException ex) {
throw new ReportableException("Invalid service URL (" + ex.getMessage() + ")");
}
}
@ -415,7 +415,7 @@ class ProjectGenerationRequest {
}
if (this.output != null) {
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;
}

View File

@ -157,7 +157,7 @@ public class OptionHandler {
OptionHelpAdapter(OptionDescriptor descriptor) {
this.options = new LinkedHashSet<>();
for (String option : descriptor.options()) {
this.options.add((option.length() == 1 ? "-" : "--") + option);
this.options.add((option.length() != 1 ? "--" : "-") + option);
}
if (this.options.contains("--cp")) {
this.options.remove("--cp");

View File

@ -73,7 +73,7 @@ public class CommandCompleter extends StringsCompleter {
public int complete(String buffer, int cursor, List<CharSequence> candidates) {
int completionIndex = super.complete(buffer, cursor, candidates);
int spaceIndex = buffer.indexOf(' ');
String commandName = (spaceIndex == -1) ? "" : buffer.substring(0, spaceIndex);
String commandName = ((spaceIndex != -1) ? buffer.substring(0, spaceIndex) : "");
if (!"".equals(commandName.trim())) {
for (Command command : this.commands) {
if (command.getName().equals(commandName)) {
@ -129,7 +129,7 @@ public class CommandCompleter extends StringsCompleter {
OptionHelpLine(OptionHelp optionHelp) {
StringBuilder options = new StringBuilder();
for (String option : optionHelp.getOptions()) {
options.append(options.length() == 0 ? "" : ", ");
options.append(options.length() != 0 ? ", " : "");
options.append(option);
}
this.options = options.toString();

View File

@ -140,7 +140,7 @@ public class Shell {
private void printBanner() {
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("Hit TAB to complete. Type 'help' and hit "
+ "RETURN for help, and 'exit' to quit."));

View File

@ -54,7 +54,7 @@ public class ShellPrompts {
* @return the current prompt
*/
public String getPrompt() {
return this.prompts.isEmpty() ? DEFAULT_PROMPT : this.prompts.peek();
return (this.prompts.isEmpty() ? DEFAULT_PROMPT : this.prompts.peek());
}
}

View File

@ -222,8 +222,8 @@ public class DependencyManagementBomTransformation
return new UrlModelSource(
Grape.getInstance().resolve(null, dependency)[0].toURL());
}
catch (MalformedURLException e) {
throw new UnresolvableModelException(e.getMessage(), groupId, artifactId,
catch (MalformedURLException ex) {
throw new UnresolvableModelException(ex.getMessage(), groupId, artifactId,
version);
}
}

View File

@ -115,7 +115,7 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader {
InputStream resourceStream = super.getResourceAsStream(name);
if (resourceStream == null) {
byte[] bytes = this.classResources.get(name);
resourceStream = bytes == null ? null : new ByteArrayInputStream(bytes);
resourceStream = (bytes != null ? new ByteArrayInputStream(bytes) : null);
}
return resourceStream;
}

View File

@ -42,13 +42,13 @@ public class DependencyManagementArtifactCoordinatesResolver
@Override
public String getGroupId(String artifactId) {
Dependency dependency = find(artifactId);
return (dependency == null ? null : dependency.getGroupId());
return (dependency != null ? dependency.getGroupId() : null);
}
@Override
public String getArtifactId(String id) {
Dependency dependency = find(id);
return dependency == null ? null : dependency.getArtifactId();
return (dependency != null ? dependency.getArtifactId() : null);
}
private Dependency find(String id) {
@ -69,7 +69,7 @@ public class DependencyManagementArtifactCoordinatesResolver
@Override
public String getVersion(String module) {
Dependency dependency = find(module);
return dependency == null ? null : dependency.getVersion();
return (dependency != null ? dependency.getVersion() : null);
}
}

View File

@ -197,7 +197,7 @@ public class AetherGrapeEngine implements GrapeEngine {
private boolean isTransitive(Map<?, ?> dependencyMap) {
Boolean transitive = (Boolean) dependencyMap.get("transitive");
return (transitive == null ? true : transitive);
return (transitive != null ? transitive : true);
}
private List<Dependency> getDependencies(DependencyResult dependencyResult) {
@ -219,7 +219,7 @@ public class AetherGrapeEngine implements GrapeEngine {
private GroovyClassLoader getClassLoader(Map args) {
GroovyClassLoader classLoader = (GroovyClassLoader) args.get("classLoader");
return (classLoader == null ? this.classLoader : classLoader);
return (classLoader != null ? classLoader : this.classLoader);
}
@Override

View File

@ -51,8 +51,9 @@ public class DefaultRepositorySystemSessionAutoConfiguration
ProxySelector existing = session.getProxySelector();
if (existing == null || !(existing instanceof CompositeProxySelector)) {
JreProxySelector fallback = new JreProxySelector();
ProxySelector selector = existing == null ? fallback
: new CompositeProxySelector(Arrays.asList(existing, fallback));
ProxySelector selector = (existing != null
? new CompositeProxySelector(Arrays.asList(existing, fallback))
: fallback);
session.setProxySelector(selector);
}
}

View File

@ -67,7 +67,7 @@ public class DependencyResolutionContext {
dependency = this.managedDependencyByGroupAndArtifact
.get(getIdentifier(groupId, artifactId));
}
return dependency != null ? dependency.getArtifact().getVersion() : null;
return (dependency != null ? dependency.getArtifact().getVersion() : null);
}
public List<Dependency> getManagedDependencies() {
@ -104,9 +104,10 @@ public class DependencyResolutionContext {
this.managedDependencyByGroupAndArtifact.put(getIdentifier(aetherDependency),
aetherDependency);
}
this.dependencyManagement = this.dependencyManagement == null
? dependencyManagement : new CompositeDependencyManagement(
dependencyManagement, this.dependencyManagement);
this.dependencyManagement = (this.dependencyManagement != null
? new CompositeDependencyManagement(dependencyManagement,
this.dependencyManagement)
: dependencyManagement);
this.artifactCoordinatesResolver = new DependencyManagementArtifactCoordinatesResolver(
this.dependencyManagement);
}

View File

@ -116,8 +116,8 @@ public class MavenSettingsReader {
try {
this._cipher = new DefaultPlexusCipher();
}
catch (PlexusCipherException e) {
throw new IllegalStateException(e);
catch (PlexusCipherException ex) {
throw new IllegalStateException(ex);
}
}

View File

@ -119,8 +119,8 @@ public abstract class AbstractHttpClientMockTests {
try {
HttpEntity entity = mock(HttpEntity.class);
given(entity.getContent()).willReturn(new ByteArrayInputStream(content));
Header contentTypeHeader = contentType != null
? new BasicHeader("Content-Type", contentType) : null;
Header contentTypeHeader = (contentType != null
? new BasicHeader("Content-Type", contentType) : null);
given(entity.getContentType()).willReturn(contentTypeHeader);
given(response.getEntity()).willReturn(entity);
return entity;
@ -138,7 +138,7 @@ public abstract class AbstractHttpClientMockTests {
protected void mockHttpHeader(CloseableHttpResponse response, String headerName,
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);
}

View File

@ -85,8 +85,8 @@ public class RemoteDevToolsAutoConfiguration {
public HandlerMapper remoteDevToolsHealthCheckHandlerMapper() {
Handler handler = new HttpStatusHandler();
return new UrlHandlerMapper(
(this.serverProperties.getServlet().getContextPath() == null ? ""
: this.serverProperties.getServlet().getContextPath())
(this.serverProperties.getServlet().getContextPath() != null
? this.serverProperties.getServlet().getContextPath() : "")
+ this.properties.getRemote().getContextPath(),
handler);
}
@ -127,8 +127,8 @@ public class RemoteDevToolsAutoConfiguration {
@Bean
@ConditionalOnMissingBean(name = "remoteRestartHandlerMapper")
public UrlHandlerMapper remoteRestartHandlerMapper(HttpRestartServer server) {
String url = (this.serverProperties.getServlet().getContextPath() == null ? ""
: this.serverProperties.getServlet().getContextPath())
String url = (this.serverProperties.getServlet().getContextPath() != null
? this.serverProperties.getServlet().getContextPath() : "")
+ this.properties.getRemote().getContextPath() + "/restart";
logger.warn("Listening for remote restart updates on " + url);
Handler handler = new HttpRestartServerHandler(server);

View File

@ -44,7 +44,7 @@ public class DevToolsHomePropertiesPostProcessor implements EnvironmentPostProce
public void postProcessEnvironment(ConfigurableEnvironment environment,
SpringApplication application) {
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()) {
FileSystemResource resource = new FileSystemResource(propertyFile);
Properties properties;

View File

@ -133,7 +133,7 @@ public class ClassPathChangeUploader
private void logUpload(ClassLoaderFiles classLoaderFiles) {
int size = classLoaderFiles.size();
logger.info(
"Uploaded " + size + " class " + (size == 1 ? "resource" : "resources"));
"Uploaded " + size + " class " + (size != 1 ? "resources" : "resource"));
}
private byte[] serialize(ClassLoaderFiles classLoaderFiles) throws IOException {
@ -160,10 +160,10 @@ public class ClassPathChangeUploader
private ClassLoaderFile asClassLoaderFile(ChangedFile changedFile)
throws IOException {
ClassLoaderFile.Kind kind = TYPE_MAPPINGS.get(changedFile.getType());
byte[] bytes = (kind == Kind.DELETED ? null
: FileCopyUtils.copyToByteArray(changedFile.getFile()));
long lastModified = (kind == Kind.DELETED ? System.currentTimeMillis()
: changedFile.getFile().lastModified());
byte[] bytes = (kind != Kind.DELETED
? FileCopyUtils.copyToByteArray(changedFile.getFile()) : null);
long lastModified = (kind != Kind.DELETED ? changedFile.getFile().lastModified()
: System.currentTimeMillis());
return new ClassLoaderFile(kind, lastModified, bytes);
}

View File

@ -55,7 +55,7 @@ public class ClassLoaderFile implements Serializable {
*/
public ClassLoaderFile(Kind kind, long lastModified, byte[] contents) {
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 ")
+ "be null");
this.kind = kind;

View File

@ -88,8 +88,8 @@ public class HttpTunnelConnection implements TunnelConnection {
throw new IllegalArgumentException("Malformed URL '" + url + "'");
}
this.requestFactory = requestFactory;
this.executor = (executor == null
? Executors.newCachedThreadPool(new TunnelThreadFactory()) : executor);
this.executor = (executor != null ? executor
: Executors.newCachedThreadPool(new TunnelThreadFactory()));
}
@Override

View File

@ -139,7 +139,7 @@ public class ClassPathChangeUploaderTests {
private void assertClassFile(ClassLoaderFile file, String content, Kind kind) {
assertThat(file.getContents())
.isEqualTo(content == null ? null : content.getBytes());
.isEqualTo(content != null ? content.getBytes() : null);
assertThat(file.getKind()).isEqualTo(kind);
}

View File

@ -45,8 +45,8 @@ public class SpockTestRestTemplateExample {
ObjectProvider<RestTemplateBuilder> builderProvider,
Environment environment) {
RestTemplateBuilder builder = builderProvider.getIfAvailable();
TestRestTemplate template = builder == null ? new TestRestTemplate()
: new TestRestTemplate(builder);
TestRestTemplate template = (builder != null ? new TestRestTemplate(builder)
: new TestRestTemplate());
template.setUriTemplateHandler(new LocalHostUriTemplateHandler(environment));
return template;
}

View File

@ -31,6 +31,7 @@ import org.springframework.test.context.junit4.SpringRunner;
*
* @author Stephane Nicoll
*/
@SuppressWarnings("unused")
// tag::test[]
@RunWith(SpringRunner.class)
@SpringBootTest(properties = "spring.jmx.enabled=true")
@ -43,7 +44,6 @@ public class SampleJmxTests {
@Test
public void exampleTest() {
// ...
}
}

View File

@ -105,8 +105,8 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
}
Annotation mergedAnnotation = AnnotatedElementUtils.getMergedAnnotation(source,
annotationType);
return mergedAnnotation != null ? mergedAnnotation
: findMergedAnnotation(source.getSuperclass(), annotationType);
return (mergedAnnotation != null ? mergedAnnotation
: findMergedAnnotation(source.getSuperclass(), annotationType));
}
private void collectProperties(Annotation annotation, Method attribute,
@ -143,8 +143,8 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
private String getName(PropertyMapping typeMapping, PropertyMapping attributeMapping,
Method attribute) {
String prefix = (typeMapping == null ? "" : typeMapping.value());
String name = (attributeMapping == null ? "" : attributeMapping.value());
String prefix = (typeMapping != null ? typeMapping.value() : "");
String name = (attributeMapping != null ? attributeMapping.value() : "");
if (!StringUtils.hasText(name)) {
name = toKebabCase(attribute.getName());
}

View File

@ -115,10 +115,10 @@ class PropertyMappingContextCustomizer implements ContextCustomizer {
private String getAnnotationsDescription(Set<Class<?>> annotations) {
StringBuilder result = new StringBuilder();
for (Class<?> annotation : annotations) {
result.append(result.length() == 0 ? "" : ", ");
result.append(result.length() != 0 ? ", " : "");
result.append("@" + ClassUtils.getShortName(annotation));
}
result.insert(0, annotations.size() == 1 ? "annotation " : "annotations ");
result.insert(0, annotations.size() != 1 ? "annotations " : "annotation ");
return result.toString();
}

View File

@ -168,10 +168,10 @@ class ImportsContextCustomizer implements ContextCustomizer {
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
BeanDefinition definition = this.beanFactory
.getBeanDefinition(ImportsConfiguration.BEAN_NAME);
Object testClass = (definition == null ? null
: definition.getAttribute(TEST_CLASS_ATTRIBUTE));
return (testClass == null ? NO_IMPORTS
: new String[] { ((Class<?>) testClass).getName() });
Object testClass = (definition != null
? definition.getAttribute(TEST_CLASS_ATTRIBUTE) : null);
return (testClass != null ? new String[] { ((Class<?>) testClass).getName() }
: NO_IMPORTS);
}
}

View File

@ -79,7 +79,7 @@ final class SpringBootConfigurationFinder {
private String getParentPackage(String sourcePackage) {
int lastDot = sourcePackage.lastIndexOf('.');
return (lastDot == -1 ? "" : sourcePackage.substring(0, lastDot));
return (lastDot != -1 ? sourcePackage.substring(0, lastDot) : "");
}
/**

View File

@ -44,6 +44,7 @@ import org.springframework.core.annotation.Order;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.ResourceLoader;
import org.springframework.test.context.ContextConfigurationAttributes;
import org.springframework.test.context.ContextCustomizer;
import org.springframework.test.context.ContextLoader;
@ -109,11 +110,11 @@ public class SpringBootContextLoader extends AbstractContextLoader {
if (!ObjectUtils.isEmpty(config.getActiveProfiles())) {
setActiveProfiles(environment, config.getActiveProfiles());
}
ResourceLoader resourceLoader = (application.getResourceLoader() != null
? application.getResourceLoader()
: new DefaultResourceLoader(getClass().getClassLoader()));
TestPropertySourceUtils.addPropertiesFilesToEnvironment(environment,
application.getResourceLoader() == null
? new DefaultResourceLoader(getClass().getClassLoader())
: application.getResourceLoader(),
config.getPropertySourceLocations());
resourceLoader, config.getPropertySourceLocations());
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment,
getInlinedProperties(config));
application.setEnvironment(environment);

View File

@ -164,8 +164,8 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
WebAppConfiguration webAppConfiguration = AnnotatedElementUtils
.findMergedAnnotation(mergedConfig.getTestClass(),
WebAppConfiguration.class);
String resourceBasePath = (webAppConfiguration == null ? "src/main/webapp"
: webAppConfiguration.value());
String resourceBasePath = (webAppConfiguration != null
? webAppConfiguration.value() : "src/main/webapp");
mergedConfig = new WebMergedContextConfiguration(mergedConfig,
resourceBasePath);
}
@ -313,17 +313,17 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
*/
protected WebEnvironment getWebEnvironment(Class<?> testClass) {
SpringBootTest annotation = getAnnotation(testClass);
return (annotation == null ? null : annotation.webEnvironment());
return (annotation != null ? annotation.webEnvironment() : null);
}
protected Class<?>[] getClasses(Class<?> testClass) {
SpringBootTest annotation = getAnnotation(testClass);
return (annotation == null ? null : annotation.classes());
return (annotation != null ? annotation.classes() : null);
}
protected String[] getProperties(Class<?> testClass) {
SpringBootTest annotation = getAnnotation(testClass);
return (annotation == null ? null : annotation.properties());
return (annotation != null ? annotation.properties() : null);
}
protected SpringBootTest getAnnotation(Class<?> testClass) {

View File

@ -75,7 +75,7 @@ public final class JsonContent<T> implements AssertProvider<JsonContentAssert> {
@Override
public String toString() {
return "JsonContent " + this.json
+ (this.type == null ? "" : " created from " + this.type);
+ (this.type != null ? " created from " + this.type : "");
}
}

View File

@ -991,7 +991,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
}
try {
return JSONCompare.compareJSON(
(expectedJson == null ? null : expectedJson.toString()),
(expectedJson != null ? expectedJson.toString() : null),
this.actual.toString(), compareMode);
}
catch (Exception ex) {
@ -1009,7 +1009,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
}
try {
return JSONCompare.compareJSON(
(expectedJson == null ? null : expectedJson.toString()),
(expectedJson != null ? expectedJson.toString() : null),
this.actual.toString(), comparator);
}
catch (Exception ex) {
@ -1054,7 +1054,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
JsonPathValue(CharSequence expression, Object... args) {
org.springframework.util.Assert.hasText(
(expression == null ? null : expression.toString()),
(expression != null ? expression.toString() : null),
"expression must not be null or empty");
this.expression = String.format(expression.toString(), args);
this.jsonPath = JsonPath.compile(this.expression);
@ -1107,7 +1107,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
public Object getValue(boolean required) {
try {
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) {
if (!required) {

View File

@ -43,7 +43,7 @@ class JsonLoader {
JsonLoader(Class<?> resourceLoadClass, Charset charset) {
this.resourceLoadClass = resourceLoadClass;
this.charset = charset == null ? StandardCharsets.UTF_8 : charset;
this.charset = (charset != null ? charset : StandardCharsets.UTF_8);
}
Class<?> getResourceLoadClass() {

View File

@ -63,7 +63,7 @@ public final class ObjectContent<T> implements AssertProvider<ObjectContentAsser
@Override
public String toString() {
return "ObjectContent " + this.object
+ (this.type == null ? "" : " created from " + this.type);
+ (this.type != null ? " created from " + this.type : "");
}
}

View File

@ -186,7 +186,7 @@ class JsonReader {
try {
return Deprecation.Level.valueOf(value.toUpperCase(Locale.ENGLISH));
}
catch (IllegalArgumentException e) {
catch (IllegalArgumentException ex) {
// let's use the default
}
}

View File

@ -50,7 +50,7 @@ public abstract class AbstractConfigurationMetadataTests {
assertThat(actual).isNotNull();
assertThat(actual.getId()).isEqualTo(id);
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.getDefaultValue()).isEqualTo(defaultValue);
}

View File

@ -390,7 +390,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
this.metadataCollector.add(ItemMetadata.newGroup(nestedPrefix,
this.typeUtils.getQualifiedName(returnElement),
this.typeUtils.getQualifiedName(element),
(getter == null ? null : getter.toString())));
(getter != null ? getter.toString() : null)));
processTypeElement(nestedPrefix, (TypeElement) returnElement, source);
}
}

View File

@ -156,8 +156,8 @@ class TypeElementMembers {
}
private String getAccessorName(String methodName) {
String name = methodName.startsWith("is") ? methodName.substring(2)
: methodName.substring(3);
String name = (methodName.startsWith("is") ? methodName.substring(2)
: methodName.substring(3));
name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
return name;
}

View File

@ -139,8 +139,8 @@ class TypeUtils {
}
public String getJavaDoc(Element element) {
String javadoc = (element == null ? null
: this.env.getElementUtils().getDocComment(element));
String javadoc = (element != null
? this.env.getElementUtils().getDocComment(element) : null);
if (javadoc != null) {
javadoc = javadoc.trim();
}

View File

@ -35,7 +35,7 @@ final class Trees extends ReflectionWrapper {
public Tree getTree(Element element) throws Exception {
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 {

View File

@ -43,7 +43,7 @@ class VariableTree extends ReflectionWrapper {
public ExpressionTree getInitializer() throws Exception {
Object instance = findMethod("getInitializer").invoke(getInstance());
return (instance == null ? null : new ExpressionTree(instance));
return (instance != null ? new ExpressionTree(instance) : null);
}
@SuppressWarnings("unchecked")

View File

@ -178,7 +178,7 @@ public class ConfigurationMetadata {
}
public static String nestedPrefix(String prefix, String name) {
String nestedPrefix = (prefix == null ? "" : prefix);
String nestedPrefix = (prefix != null ? prefix : "");
String dashedName = toDashedCase(name);
nestedPrefix += ("".equals(nestedPrefix) ? dashedName : "." + dashedName);
return nestedPrefix;

View File

@ -108,7 +108,7 @@ public class ItemDeprecation {
}
private int nullSafeHashCode(Object o) {
return (o == null ? 0 : o.hashCode());
return (o != null ? o.hashCode() : 0);
}
}

View File

@ -61,11 +61,11 @@ public final class ItemMetadata implements Comparable<ItemMetadata> {
while (prefix != null && prefix.endsWith(".")) {
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) {
fullName.append(".");
}
fullName.append(name == null ? "" : ConfigurationMetadata.toDashedCase(name));
fullName.append(name != null ? ConfigurationMetadata.toDashedCase(name) : "");
return fullName.toString();
}
@ -196,7 +196,7 @@ public final class ItemMetadata implements Comparable<ItemMetadata> {
}
private int nullSafeHashCode(Object o) {
return (o == null ? 0 : o.hashCode());
return (o != null ? o.hashCode() : 0);
}
@Override

View File

@ -98,8 +98,8 @@ public class TestConfigurationMetadataAnnotationProcessor
}
return this.metadata;
}
catch (IOException e) {
throw new RuntimeException("Failed to read metadata from disk", e);
catch (IOException ex) {
throw new RuntimeException("Failed to read metadata from disk", ex);
}
}

View File

@ -109,8 +109,8 @@ public class DefaultLaunchScript implements LaunchScript {
}
}
else {
value = (defaultValue == null ? matcher.group(0)
: defaultValue.substring(1));
value = (defaultValue != null ? defaultValue.substring(1)
: matcher.group(0));
}
matcher.appendReplacement(expanded, value.replace("$", "\\$"));
}

View File

@ -356,7 +356,7 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable {
@Override
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) {
this.headerStream = null;
return read;
@ -371,8 +371,8 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable {
@Override
public int read(byte[] b, int off, int len) throws IOException {
int read = (this.headerStream == null ? -1
: this.headerStream.read(b, off, len));
int read = (this.headerStream != null ? this.headerStream.read(b, off, len)
: -1);
if (read != -1) {
this.headerStream = null;
return read;

View File

@ -63,7 +63,7 @@ public class Library {
* @param unpackRequired if the library needs to be unpacked before it can be used
*/
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.scope = scope;
this.unpackRequired = unpackRequired;

View File

@ -452,8 +452,8 @@ public abstract class MainClassFinder {
"Unable to find a single main class from the following candidates "
+ matchingMainClasses);
}
return matchingMainClasses.isEmpty() ? null
: matchingMainClasses.iterator().next().getName();
return (matchingMainClasses.isEmpty() ? null
: matchingMainClasses.iterator().next().getName());
}
}

View File

@ -116,8 +116,8 @@ public abstract class Launcher {
protected final Archive createArchive() throws Exception {
ProtectionDomain protectionDomain = getClass().getProtectionDomain();
CodeSource codeSource = protectionDomain.getCodeSource();
URI location = (codeSource == null ? null : codeSource.getLocation().toURI());
String path = (location == null ? null : location.getSchemeSpecificPart());
URI location = (codeSource != null ? codeSource.getLocation().toURI() : null);
String path = (location != null ? location.getSchemeSpecificPart() : null);
if (path == null) {
throw new IllegalStateException("Unable to determine code source archive");
}

View File

@ -38,7 +38,7 @@ public class MainMethodRunner {
*/
public MainMethodRunner(String mainClass, String[] args) {
this.mainClassName = mainClass;
this.args = (args == null ? null : args.clone());
this.args = (args != null ? args.clone() : null);
}
public void run() throws Exception {

View File

@ -434,8 +434,9 @@ public class PropertiesLauncher extends Launcher {
return SystemPropertyUtils.resolvePlaceholders(this.properties, value);
}
}
return defaultValue == null ? defaultValue
: SystemPropertyUtils.resolvePlaceholders(this.properties, defaultValue);
return (defaultValue != null
? SystemPropertyUtils.resolvePlaceholders(this.properties, defaultValue)
: defaultValue);
}
@Override

View File

@ -127,8 +127,7 @@ public class RandomAccessDataFile implements RandomAccessData {
}
/**
* {@link InputStream} implementation for the
* {@link RandomAccessDataFile}.
* {@link InputStream} implementation for the {@link RandomAccessDataFile}.
*/
private class DataInputStream extends InputStream {
@ -145,7 +144,7 @@ public class RandomAccessDataFile implements RandomAccessData {
@Override
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

View File

@ -250,7 +250,7 @@ public class Handler extends URLStreamHandler {
}
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);
if (separatorIndex == -1) {
return result + file.hashCode();
@ -319,7 +319,7 @@ public class Handler extends URLStreamHandler {
String path = name.substring(FILE_PROTOCOL.length());
File file = new File(URLDecoder.decode(path, "UTF-8"));
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) {
result = new JarFile(file);
addToRootFileCache(file, result);

View File

@ -77,7 +77,7 @@ class JarEntry extends java.util.jar.JarEntry implements FileHeader {
@Override
public Attributes getAttributes() throws IOException {
Manifest manifest = this.jarFile.getManifest();
return (manifest == null ? null : manifest.getAttributes(getName()));
return (manifest != null ? manifest.getAttributes(getName()) : null);
}
@Override

View File

@ -168,7 +168,7 @@ public class JarFile extends java.util.jar.JarFile {
@Override
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) {
try {
manifest = this.manifestSupplier.get();
@ -222,7 +222,7 @@ public class JarFile extends java.util.jar.JarFile {
if (ze instanceof JarEntry) {
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 {

View File

@ -277,7 +277,7 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable<JarEntry> {
}
private AsciiBytes applyFilter(AsciiBytes name) {
return (this.filter == null ? name : this.filter.apply(name));
return (this.filter != null ? this.filter.apply(name) : name);
}
/**

View File

@ -204,7 +204,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
return this.jarFile.size();
}
JarEntry entry = getJarEntry();
return (entry == null ? -1 : (int) entry.getSize());
return (entry != null ? (int) entry.getSize() : -1);
}
catch (IOException ex) {
return -1;
@ -219,7 +219,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
@Override
public String getContentType() {
return (this.jarEntryName == null ? null : this.jarEntryName.getContentType());
return (this.jarEntryName != null ? this.jarEntryName.getContentType() : null);
}
@Override
@ -241,7 +241,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
}
try {
JarEntry entry = getJarEntry();
return (entry == null ? 0 : entry.getTime());
return (entry != null ? entry.getTime() : 0);
}
catch (IOException ex) {
return 0;

View File

@ -155,7 +155,7 @@ public abstract class SystemPropertyUtils {
if (propVal != null) {
return propVal;
}
return properties == null ? null : properties.getProperty(placeholderName);
return (properties != null ? properties.getProperty(placeholderName) : null);
}
public static String getProperty(String key) {

View File

@ -69,9 +69,9 @@ public class ExplodedArchiveTests {
File file = this.temporaryFolder.newFile();
TestJarCreator.createTestJar(file);
this.rootFolder = StringUtils.hasText(folderName)
this.rootFolder = (StringUtils.hasText(folderName)
? this.temporaryFolder.newFolder(folderName)
: this.temporaryFolder.newFolder();
: this.temporaryFolder.newFolder());
JarFile jarFile = new JarFile(file);
Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {

View File

@ -401,8 +401,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
private void addDependencies(List<URL> urls)
throws MalformedURLException, MojoExecutionException {
FilterArtifacts filters = this.useTestClasspath ? getFilters()
: getFilters(new TestArtifactFilter());
FilterArtifacts filters = (this.useTestClasspath ? getFilters()
: getFilters(new TestArtifactFilter()));
Set<Artifact> artifacts = filterDependencies(this.project.getArtifacts(),
filters);
for (Artifact artifact : artifacts) {
@ -450,7 +450,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
public void uncaughtException(Thread thread, Throwable ex) {
if (!(ex instanceof ThreadDeath)) {
synchronized (this.monitor) {
this.exception = (this.exception == null ? ex : this.exception);
this.exception = (this.exception != null ? this.exception : ex);
}
getLog().warn(ex);
}

View File

@ -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.
* Specify each library as a {@code <dependency>} with a {@code <groupId>} and
* a {@code <artifactId>} and they will be unpacked at runtime.
* Specify each library as a {@code <dependency>} with a {@code <groupId>} and a
* {@code <artifactId>} and they will be unpacked at runtime.
* @since 1.1
*/
@Parameter
@ -156,10 +156,10 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
* jar.
* <p>
* 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
* a jar or war that has been made fully-executable. It is recommended that you only
* enable this option if you intend to execute it directly, rather than running it
* with {@code java -jar} or deploying it to a servlet container.
* use this technique. For example, {@code jar -xf} may silently fail to extract a jar
* or war that has been made fully-executable. It is recommended that you only enable
* this option if you intend to execute it directly, rather than running it with
* {@code java -jar} or deploying it to a servlet container.
* @since 1.3
*/
@Parameter(defaultValue = "false")
@ -226,7 +226,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
}
private File getTargetFile() {
String classifier = (this.classifier == null ? "" : this.classifier.trim());
String classifier = (this.classifier != null ? this.classifier.trim() : "");
if (!classifier.isEmpty() && !classifier.startsWith("-")) {
classifier = "-" + classifier;
}
@ -287,7 +287,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
}
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,

View File

@ -62,7 +62,7 @@ public class DefaultApplicationArguments implements ApplicationArguments {
@Override
public List<String> getOptionValues(String name) {
List<String> values = this.source.getOptionValues(name);
return (values == null ? null : Collections.unmodifiableList(values));
return (values != null ? Collections.unmodifiableList(values) : null);
}
@Override

View File

@ -93,7 +93,7 @@ class ExitCodeGenerators implements Iterable<ExitCodeGenerator> {
}
}
catch (Exception ex) {
exitCode = (exitCode == 0 ? 1 : exitCode);
exitCode = (exitCode != 0 ? exitCode : 1);
ex.printStackTrace();
}
}

View File

@ -107,8 +107,8 @@ public class ResourceBanner implements Banner {
}
protected String getApplicationVersion(Class<?> sourceClass) {
Package sourcePackage = (sourceClass == null ? null : sourceClass.getPackage());
return (sourcePackage == null ? null : sourcePackage.getImplementationVersion());
Package sourcePackage = (sourceClass != null ? sourceClass.getPackage() : null);
return (sourcePackage != null ? sourcePackage.getImplementationVersion() : null);
}
protected String getBootVersion() {
@ -132,14 +132,14 @@ public class ResourceBanner implements Banner {
MutablePropertySources sources = new MutablePropertySources();
String applicationTitle = getApplicationTitle(sourceClass);
Map<String, Object> titleMap = Collections.singletonMap("application.title",
(applicationTitle == null ? "" : applicationTitle));
(applicationTitle != null ? applicationTitle : ""));
sources.addFirst(new MapPropertySource("title", titleMap));
return new PropertySourcesPropertyResolver(sources);
}
protected String getApplicationTitle(Class<?> sourceClass) {
Package sourcePackage = (sourceClass == null ? null : sourceClass.getPackage());
return (sourcePackage == null ? null : sourcePackage.getImplementationTitle());
Package sourcePackage = (sourceClass != null ? sourceClass.getPackage() : null);
return (sourcePackage != null ? sourcePackage.getImplementationTitle() : null);
}
}

View File

@ -553,8 +553,8 @@ public class SpringApplication {
if (this.bannerMode == Banner.Mode.OFF) {
return null;
}
ResourceLoader resourceLoader = this.resourceLoader != null ? this.resourceLoader
: new DefaultResourceLoader(getClassLoader());
ResourceLoader resourceLoader = (this.resourceLoader != null ? this.resourceLoader
: new DefaultResourceLoader(getClassLoader()));
SpringApplicationBannerPrinter bannerPrinter = new SpringApplicationBannerPrinter(
resourceLoader, this.banner);
if (this.bannerMode == Mode.LOG) {
@ -1304,7 +1304,7 @@ public class SpringApplication {
}
catch (Exception ex) {
ex.printStackTrace();
exitCode = (exitCode == 0 ? 1 : exitCode);
exitCode = (exitCode != 0 ? exitCode : 1);
}
return exitCode;
}

View File

@ -163,7 +163,7 @@ class SpringApplicationBannerPrinter {
@Override
public void printBanner(Environment environment, Class<?> sourceClass,
PrintStream out) {
sourceClass = (sourceClass == null ? this.sourceClass : sourceClass);
sourceClass = (sourceClass != null ? sourceClass : this.sourceClass);
this.banner.printBanner(environment, sourceClass, out);
}

View File

@ -99,7 +99,7 @@ class SpringApplicationRunListeners {
}
else {
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 + ")");
}
}

Some files were not shown because too many files have changed in this diff Show More