Merge branch '2.0.x'

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

View File

@@ -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

@@ -456,8 +456,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) {
@@ -505,7 +505,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,