Merge branch '2.0.x'

pull/13941/head
Phillip Webb 6 years ago
commit 80da9cf5eb

@ -209,7 +209,7 @@ public class ConditionsReportEndpoint {
this.message = outcome.getMessage();
}
else {
this.message = (outcome.isMatch() ? "matched" : "did not match");
this.message = outcome.isMatch() ? "matched" : "did not match";
}
}

@ -69,7 +69,7 @@ public class PropertiesMeterFilter implements MeterFilter {
@Override
public MeterFilterReply accept(Meter.Id id) {
boolean enabled = lookup(this.properties.getEnable(), id, true);
return (enabled ? MeterFilterReply.NEUTRAL : MeterFilterReply.DENY);
return enabled ? MeterFilterReply.NEUTRAL : MeterFilterReply.DENY;
}
@Override

@ -224,7 +224,7 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
}
private <T> T getLast(List<T> list) {
return (CollectionUtils.isEmpty(list) ? null : list.get(list.size() - 1));
return CollectionUtils.isEmpty(list) ? null : list.get(list.size() - 1);
}
private void assertNoDuplicateOperations(EndpointBean endpointBean,

@ -61,7 +61,7 @@ public class ServletEndpointRegistrar implements ServletContextInitializer {
ExposableServletEndpoint endpoint) {
String name = endpoint.getId() + "-actuator-endpoint";
String path = this.basePath + "/" + endpoint.getRootPath();
String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*");
String urlMapping = path.endsWith("/") ? path + "*" : path + "/*";
EndpointServlet endpointServlet = endpoint.getEndpointServlet();
Dynamic registration = servletContext.addServlet(name,
endpointServlet.getServlet());

@ -188,7 +188,7 @@ public class JerseyEndpointResourceFactory {
private Response convertToJaxRsResponse(Object response, String httpMethod) {
if (response == null) {
boolean isGet = HttpMethod.GET.equals(httpMethod);
Status status = (isGet ? Status.NOT_FOUND : Status.NO_CONTENT);
Status status = isGet ? Status.NOT_FOUND : Status.NO_CONTENT;
return Response.status(status).build();
}
try {

@ -132,7 +132,7 @@ public class MetricsEndpoint {
}
private BiFunction<Double, Double, Double> mergeFunction(Statistic statistic) {
return (Statistic.MAX.equals(statistic) ? Double::max : Double::sum);
return Statistic.MAX.equals(statistic) ? Double::max : Double::sum;
}
private Map<String, Set<String>> getAvailableTags(List<Meter> meters) {

@ -123,7 +123,7 @@ public final class WebMvcTags {
private static String getPathInfo(HttpServletRequest request) {
String pathInfo = request.getPathInfo();
String uri = (StringUtils.hasText(pathInfo) ? pathInfo : "/");
String uri = StringUtils.hasText(pathInfo) ? pathInfo : "/";
return uri.replaceAll("//+", "/").replaceAll("/$", "");
}

@ -86,7 +86,7 @@ public class HttpExchangeTracer {
}
private <T> T getIfIncluded(Include include, Supplier<T> valueSupplier) {
return (this.includes.contains(include) ? valueSupplier.get() : null);
return this.includes.contains(include) ? valueSupplier.get() : null;
}
private <T> void setIfIncluded(Include include, Supplier<T> supplier,

@ -260,7 +260,7 @@ public class RabbitProperties {
}
public void setVirtualHost(String virtualHost) {
this.virtualHost = ("".equals(virtualHost) ? "/" : virtualHost);
this.virtualHost = "".equals(virtualHost) ? "/" : virtualHost;
}
public Duration getRequestedHeartbeat() {

@ -48,7 +48,7 @@ public final class ConditionMessage {
}
private ConditionMessage(ConditionMessage prior, String message) {
this.message = (prior.isEmpty() ? message : prior + "; " + message);
this.message = prior.isEmpty() ? message : prior + "; " + message;
}
/**

@ -111,7 +111,7 @@ public class ConditionOutcome {
* @return the message or {@code null}
*/
public String getMessage() {
return (this.message.isEmpty() ? null : this.message.toString());
return this.message.isEmpty() ? null : this.message.toString();
}
/**

@ -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()) {

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

@ -69,7 +69,7 @@ public class ResourceProperties {
String[] normalized = new String[staticLocations.length];
for (int i = 0; i < staticLocations.length; i++) {
String location = staticLocations[i];
normalized[i] = (location.endsWith("/") ? location : location + "/");
normalized[i] = location.endsWith("/") ? location : location + "/";
}
return normalized;
}

@ -61,7 +61,7 @@ public class WebConversionService extends DefaultFormattingConversionService {
*/
public WebConversionService(String dateFormat) {
super(false);
this.dateFormat = (StringUtils.hasText(dateFormat) ? dateFormat : null);
this.dateFormat = StringUtils.hasText(dateFormat) ? dateFormat : null;
if (this.dateFormat != null) {
addFormatters();
}

@ -152,7 +152,7 @@ public class WebServicesAutoConfiguration {
}
private String ensureTrailingSlash(String path) {
return (path.endsWith("/") ? path : path + "/");
return path.endsWith("/") ? path : path + "/";
}
}

@ -54,7 +54,7 @@ public class CommandRunner implements Iterable<Command> {
* @param name the name of the runner or {@code null}
*/
public CommandRunner(String name) {
this.name = (StringUtils.hasLength(name) ? name + " " : "");
this.name = StringUtils.hasLength(name) ? name + " " : "";
}
/**

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

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

@ -322,7 +322,7 @@ public class GroovyCompiler {
return node;
}
}
return (classes.isEmpty() ? null : classes.get(0));
return classes.isEmpty() ? null : classes.get(0);
}
}

@ -154,7 +154,7 @@ public class CliTester implements TestRule {
}
}
else {
sources[i] = (new File(arg).isAbsolute() ? arg : this.prefix + arg);
sources[i] = new File(arg).isAbsolute() ? arg : this.prefix + arg;
}
}
return sources;

@ -101,7 +101,7 @@ public class HttpTunnelConnection implements TunnelConnection {
protected final ClientHttpRequest createRequest(boolean hasPayload)
throws IOException {
HttpMethod method = (hasPayload ? HttpMethod.POST : HttpMethod.GET);
HttpMethod method = hasPayload ? HttpMethod.POST : HttpMethod.GET;
return this.requestFactory.createRequest(this.uri, method);
}

@ -161,8 +161,7 @@ public class HttpTunnelConnectionTests {
private TunnelChannel openTunnel(boolean singleThreaded) throws Exception {
HttpTunnelConnection connection = new HttpTunnelConnection(this.url,
this.requestFactory,
(singleThreaded ? new CurrentThreadExecutor() : null));
this.requestFactory, singleThreaded ? new CurrentThreadExecutor() : null);
return connection.open(this.incomingChannel, this.closeable);
}

@ -164,7 +164,7 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
private String dotAppend(String prefix, String postfix) {
if (StringUtils.hasText(prefix)) {
return (prefix.endsWith(".") ? prefix + postfix : prefix + "." + postfix);
return prefix.endsWith(".") ? prefix + postfix : prefix + "." + postfix;
}
return postfix;
}

@ -991,7 +991,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
}
try {
return JSONCompare.compareJSON(
((expectedJson != null) ? expectedJson.toString() : null),
(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) ? expectedJson.toString() : null),
(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) ? expression.toString() : null),
(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);

@ -178,7 +178,7 @@ class JsonReader {
.setReplacement(deprecationJsonObject.optString("replacement", null));
return deprecation;
}
return (object.optBoolean("deprecated") ? new Deprecation() : null);
return object.optBoolean("deprecated") ? new Deprecation() : null;
}
private Deprecation.Level parseDeprecationLevel(String value) {

@ -302,7 +302,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|| isDeprecated(source);
this.metadataCollector.add(ItemMetadata.newProperty(prefix, name,
dataType, sourceType, null, description, defaultValue,
(deprecated ? getItemDeprecation(getter) : null)));
deprecated ? getItemDeprecation(getter) : null));
}
});
}
@ -344,7 +344,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
boolean deprecated = isDeprecated(field) || isDeprecated(source);
this.metadataCollector.add(ItemMetadata.newProperty(prefix, name,
dataType, sourceType, null, description, defaultValue,
(deprecated ? new ItemDeprecation() : null)));
deprecated ? new ItemDeprecation() : null));
}
});
}

@ -111,7 +111,7 @@ public class JsonMarshaller {
.setReplacement(deprecationJsonObject.optString("replacement", null));
return deprecation;
}
return (object.optBoolean("deprecated") ? new ItemDeprecation() : null);
return object.optBoolean("deprecated") ? new ItemDeprecation() : null;
}
private ItemHint toItemHint(JSONObject object) throws Exception {

@ -43,7 +43,7 @@ public class JavaExecutable {
private File findInJavaHome(String javaHome) {
File bin = new File(new File(javaHome), "bin");
File command = new File(bin, "java.exe");
command = (command.exists() ? command : new File(bin, "java"));
command = command.exists() ? command : new File(bin, "java");
Assert.state(command.exists(), () -> "Unable to find java in " + javaHome);
return command;
}

@ -304,7 +304,7 @@ public class PropertiesLauncher extends Launcher {
for (String path : commaSeparatedPaths.split(",")) {
path = cleanupPath(path);
// "" means the user wants root of archive but not current directory
path = ("".equals(path) ? "/" : path);
path = "".equals(path) ? "/" : path;
paths.add(path);
}
if (paths.isEmpty()) {

@ -124,8 +124,8 @@ public class Handler extends URLStreamHandler {
private void log(boolean warning, String message, Exception cause) {
try {
Logger.getLogger(getClass().getName())
.log((warning ? Level.WARNING : Level.FINEST), message, cause);
Level level = warning ? Level.WARNING : Level.FINEST;
Logger.getLogger(getClass().getName()).log(level, message, cause);
}
catch (Exception ex) {
if (warning) {

@ -214,7 +214,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
@Override
public Object getContent() throws IOException {
connect();
return (this.jarEntryName.isEmpty() ? this.jarFile : super.getContent());
return this.jarEntryName.isEmpty() ? this.jarFile : super.getContent();
}
@Override
@ -386,7 +386,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
private String deduceContentType() {
// Guess the content type, don't bother with streams as mark is not supported
String type = (isEmpty() ? "x-java/jar" : null);
String type = isEmpty() ? "x-java/jar" : null;
type = (type != null) ? type : guessContentTypeFromName(toString());
type = (type != null) ? type : "content/unknown";
return type;

@ -200,7 +200,7 @@ public class ImageBanner implements Banner {
private void printBanner(BufferedImage image, int margin, boolean invert,
PrintStream out) {
AnsiElement background = (invert ? AnsiBackground.BLACK : AnsiBackground.DEFAULT);
AnsiElement background = invert ? AnsiBackground.BLACK : AnsiBackground.DEFAULT;
out.print(AnsiOutput.encode(AnsiColor.DEFAULT));
out.print(AnsiOutput.encode(background));
out.println();

@ -119,7 +119,7 @@ public class ResourceBanner implements Banner {
if (version == null) {
return "";
}
return (format ? " (v" + version + ")" : version);
return format ? " (v" + version + ")" : version;
}
private PropertyResolver getAnsiResolver() {

@ -99,7 +99,7 @@ class SpringApplicationBannerPrinter {
String location = environment.getProperty(BANNER_IMAGE_LOCATION_PROPERTY);
if (StringUtils.hasLength(location)) {
Resource resource = this.resourceLoader.getResource(location);
return (resource.exists() ? new ImageBanner(resource) : null);
return resource.exists() ? new ImageBanner(resource) : null;
}
for (String ext : IMAGE_EXTENSION) {
Resource resource = this.resourceLoader.getResource("banner." + ext);

@ -66,7 +66,7 @@ public class ContextIdApplicationContextInitializer implements
private String getApplicationId(ConfigurableEnvironment environment) {
String name = environment.getProperty("spring.application.name");
return (StringUtils.hasText(name) ? name : "application");
return StringUtils.hasText(name) ? name : "application";
}
/**

@ -441,7 +441,7 @@ public class ConfigFileApplicationListener
DocumentConsumer consumer) {
getSearchLocations().forEach((location) -> {
boolean isFolder = location.endsWith("/");
Set<String> names = (isFolder ? getSearchNames() : NO_SEARCH_NAMES);
Set<String> names = isFolder ? getSearchNames() : NO_SEARCH_NAMES;
names.forEach(
(name) -> load(location, name, profile, filterFactory, consumer));
});

@ -310,7 +310,7 @@ public class LoggingApplicationListener implements GenericApplicationListener {
private void setLogLevel(LoggingSystem system, String name, String level) {
try {
name = (name.equalsIgnoreCase(LoggingSystem.ROOT_LOGGER_NAME) ? null : name);
name = name.equalsIgnoreCase(LoggingSystem.ROOT_LOGGER_NAME) ? null : name;
system.setLogLevel(name, coerceLogLevel(level));
}
catch (RuntimeException ex) {

@ -70,7 +70,7 @@ class MapBinder extends AggregateBinder<Map<Object, Object>> {
}
new EntryBinder(name, resolvedTarget, elementBinder).bindEntries(source, map);
}
return (map.isEmpty() ? null : map);
return map.isEmpty() ? null : map;
}
private Bindable<?> resolveTarget(Bindable<?> target) {

@ -319,17 +319,17 @@ public final class ConfigurationPropertyName
int l1 = e1.length();
int l2 = e2.length();
boolean indexed1 = isIndexed(e1);
int offset1 = (indexed1 ? 1 : 0);
int offset1 = indexed1 ? 1 : 0;
boolean indexed2 = isIndexed(e2);
int offset2 = (indexed2 ? 1 : 0);
int offset2 = indexed2 ? 1 : 0;
int i1 = offset1;
int i2 = offset2;
while (i1 < l1 - offset1) {
if (i2 >= l2 - offset2) {
return false;
}
char ch1 = (indexed1 ? e1.charAt(i1) : Character.toLowerCase(e1.charAt(i1)));
char ch2 = (indexed2 ? e2.charAt(i2) : Character.toLowerCase(e2.charAt(i2)));
char ch1 = indexed1 ? e1.charAt(i1) : Character.toLowerCase(e1.charAt(i1));
char ch2 = indexed2 ? e2.charAt(i2) : Character.toLowerCase(e2.charAt(i2));
if (ch1 == '-' || ch1 == '_') {
i1++;
}
@ -372,7 +372,7 @@ public final class ConfigurationPropertyName
private int getElementHashCode(CharSequence element) {
int hash = 0;
boolean indexed = isIndexed(element);
int offset = (indexed ? 1 : 0);
int offset = indexed ? 1 : 0;
for (int i = 0 + offset; i < element.length() - offset; i++) {
char ch = (indexed ? element.charAt(i)
: Character.toLowerCase(element.charAt(i)));

@ -44,7 +44,7 @@ class FilteredConfigurationPropertiesSource implements ConfigurationPropertySour
public ConfigurationProperty getConfigurationProperty(
ConfigurationPropertyName name) {
boolean filtered = getFilter().test(name);
return (filtered ? getSource().getConfigurationProperty(name) : null);
return filtered ? getSource().getConfigurationProperty(name) : null;
}
@Override

@ -100,7 +100,7 @@ final class SystemEnvironmentPropertyMapper implements PropertyMapper {
private CharSequence processElementValue(CharSequence value) {
String result = value.toString().toLowerCase(Locale.ENGLISH);
return (isNumber(result) ? "[" + result + "]" : result);
return isNumber(result) ? "[" + result + "]" : result;
}
private static boolean isNumber(String string) {

@ -140,7 +140,7 @@ public class ApplicationHome {
if (homeDir.isFile()) {
homeDir = homeDir.getParentFile();
}
homeDir = (homeDir.exists() ? homeDir : new File("."));
homeDir = homeDir.exists() ? homeDir : new File(".");
return homeDir.getAbsoluteFile();
}

@ -67,7 +67,7 @@ public class ServerPortInfoApplicationContextInitializer
private String getName(WebServerApplicationContext context) {
String name = context.getServerNamespace();
return (StringUtils.hasText(name) ? name : "server");
return StringUtils.hasText(name) ? name : "server";
}
private void setPortProperty(ApplicationContext context, String propertyName,

@ -320,7 +320,7 @@ public class TomcatWebServer implements WebServer {
StringBuilder ports = new StringBuilder();
for (Connector connector : this.tomcat.getService().findConnectors()) {
ports.append((ports.length() != 0) ? " " : "");
int port = (localPort ? connector.getLocalPort() : connector.getPort());
int port = localPort ? connector.getLocalPort() : connector.getPort();
ports.append(port + " (" + connector.getScheme() + ")");
}
return ports.toString();

@ -178,7 +178,7 @@ public class ServletContextInitializerBeans
private MultipartConfigElement getMultipartConfig(ListableBeanFactory beanFactory) {
List<Entry<String, MultipartConfigElement>> beans = getOrderedBeansOfType(
beanFactory, MultipartConfigElement.class);
return (beans.isEmpty() ? null : beans.get(0).getValue());
return beans.isEmpty() ? null : beans.get(0).getValue();
}
protected <T> void addAsRegistrationBean(ListableBeanFactory beanFactory,

@ -712,7 +712,7 @@ public abstract class AbstractServletWebServerFactoryTests {
}
private String getStoreType(String keyStore) {
return (keyStore.endsWith(".p12") ? "pkcs12" : null);
return keyStore.endsWith(".p12") ? "pkcs12" : null;
}
@Test

@ -42,7 +42,7 @@ public class ChatService {
@Disconnect
public void onDisconnect(AtmosphereResourceEvent event) {
this.logger.info("Client {} disconnected [{}]", event.getResource().uuid(),
(event.isCancelled() ? "cancelled" : "closed"));
event.isCancelled() ? "cancelled" : "closed");
}
@org.atmosphere.config.service.Message(encoders = JacksonEncoderDecoder.class, decoders = JacksonEncoderDecoder.class)

Loading…
Cancel
Save