Merge branch '1.5.x' into 2.0.x

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

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