From ffc883b005b22c22873d7dcf78335bda6c9ea7f4 Mon Sep 17 00:00:00 2001 From: igor-suhorukov Date: Sat, 17 Mar 2018 01:32:32 +0300 Subject: [PATCH 1/2] Iterate map by using lambda function Closes gh-12528 --- .../ConfigurationPropertiesReportEndpoint.java | 12 ++++-------- .../actuate/health/AbstractHealthAggregator.java | 4 +--- .../CloudFoundryVcapEnvironmentPostProcessor.java | 8 +++----- ...ngApplicationJsonEnvironmentPostProcessor.java | 6 ++---- .../jetty/JettyServletWebServerFactory.java | 10 ++-------- .../tomcat/TomcatServletWebServerFactory.java | 15 +++------------ .../embedded/undertow/FileSessionPersistence.java | 15 ++++++--------- .../undertow/UndertowServletWebServerFactory.java | 10 ++-------- .../boot/web/server/MimeMappings.java | 4 +--- .../servlet/ServletContextInitializerBeans.java | 9 ++++----- .../ServletWebServerApplicationContext.java | 8 ++++---- ...opertySourceEnvironmentPostProcessorTests.java | 10 +++++----- .../AbstractServletWebServerFactoryTests.java | 9 ++------- 13 files changed, 39 insertions(+), 81 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java index d177ee41f7..3d611ee3ec 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java @@ -112,13 +112,11 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext Map beans = getConfigurationPropertiesBeans(context, beanFactoryMetadata); Map beanDescriptors = new HashMap<>(); - for (Map.Entry entry : beans.entrySet()) { - String beanName = entry.getKey(); - Object bean = entry.getValue(); + beans.forEach((beanName, bean) -> { String prefix = extractPrefix(context, beanFactoryMetadata, beanName); beanDescriptors.put(beanName, new ConfigurationPropertiesBeanDescriptor( prefix, sanitize(prefix, safeSerialize(mapper, bean, prefix)))); - } + }); return new ContextConfigurationProperties(beanDescriptors, context.getParent() == null ? null : context.getParent().getId()); } @@ -229,10 +227,8 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext */ @SuppressWarnings("unchecked") private Map sanitize(String prefix, Map map) { - for (Map.Entry entry : map.entrySet()) { - String key = entry.getKey(); + map.forEach((key, value) -> { String qualifiedKey = (prefix.isEmpty() ? prefix : prefix + ".") + key; - Object value = entry.getValue(); if (value instanceof Map) { map.put(key, sanitize(qualifiedKey, (Map) value)); } @@ -244,7 +240,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext value = this.sanitizer.sanitize(qualifiedKey, value); map.put(key, value); } - } + }); return map; } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthAggregator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthAggregator.java index 17b434cbb3..6b689e03c8 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthAggregator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthAggregator.java @@ -34,9 +34,7 @@ public abstract class AbstractHealthAggregator implements HealthAggregator { @Override public final Health aggregate(Map healths) { List statusCandidates = new ArrayList<>(); - for (Map.Entry entry : healths.entrySet()) { - statusCandidates.add(entry.getValue().getStatus()); - } + healths.values().forEach(health -> statusCandidates.add(health.getStatus())); Status status = aggregateStatus(statusCandidates); Map details = aggregateDetails(healths); return new Health.Builder(status, details).build(); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java index d01953d016..a6b5c4f9d3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java @@ -20,7 +20,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Properties; import org.apache.commons.logging.Log; @@ -197,9 +196,8 @@ public class CloudFoundryVcapEnvironmentPostProcessor @SuppressWarnings("unchecked") private void flatten(Properties properties, Map input, String path) { - for (Entry entry : input.entrySet()) { - String key = getFullKey(path, entry.getKey()); - Object value = entry.getValue(); + input.forEach((entryKey, value) -> { + String key = getFullKey(path, entryKey); if (value instanceof Map) { // Need a compound key flatten(properties, (Map) value, key); @@ -227,7 +225,7 @@ public class CloudFoundryVcapEnvironmentPostProcessor else { properties.put(key, value == null ? "" : value); } - } + }); } private String getFullKey(String path, String key) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java index 8cc4486ed1..3cb9c47c57 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java @@ -126,10 +126,8 @@ public class SpringApplicationJsonEnvironmentPostProcessor private void flatten(String prefix, Map result, Map map) { - prefix = (prefix == null ? "" : prefix + "."); - for (Map.Entry entry : map.entrySet()) { - extract(prefix + entry.getKey(), result, entry.getValue()); - } + String namePrefix = (prefix == null ? "" : prefix + "."); + map.forEach((key, value) -> extract(namePrefix + key, result, value)); } @SuppressWarnings("unchecked") diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java index b744cc66cc..7d44b8340b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java @@ -23,14 +23,11 @@ import java.net.InetSocketAddress; import java.net.MalformedURLException; import java.net.URL; import java.nio.channels.ReadableByteChannel; -import java.nio.charset.Charset; import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; -import java.util.Locale; -import java.util.Map; import org.eclipse.jetty.http.MimeTypes; import org.eclipse.jetty.server.AbstractConnector; @@ -249,11 +246,8 @@ public class JettyServletWebServerFactory extends AbstractServletWebServerFactor } private void addLocaleMappings(WebAppContext context) { - for (Map.Entry entry : getLocaleCharsetMappings().entrySet()) { - Locale locale = entry.getKey(); - Charset charset = entry.getValue(); - context.addLocaleEncoding(locale.toString(), charset.toString()); - } + getLocaleCharsetMappings().forEach((locale, charset) -> + context.addLocaleEncoding(locale.toString(), charset.toString())); } private File getTempDirectory() { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactory.java index dcc0090746..7913b40474 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactory.java @@ -30,8 +30,6 @@ import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; -import java.util.Map; -import java.util.Map.Entry; import java.util.Set; import javax.servlet.ServletContainerInitializer; @@ -234,12 +232,8 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto } private void addLocaleMappings(TomcatEmbeddedContext context) { - for (Map.Entry entry : getLocaleCharsetMappings().entrySet()) { - Locale locale = entry.getKey(); - Charset charset = entry.getValue(); - context.addLocaleEncodingMappingParameter(locale.toString(), - charset.toString()); - } + getLocaleCharsetMappings().forEach((locale, charset) -> + context.addLocaleEncodingMappingParameter(locale.toString(), charset.toString())); } private void configureTldSkipPatterns(TomcatEmbeddedContext context) { @@ -267,10 +261,7 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto jspServlet.setName("jsp"); jspServlet.setServletClass(getJsp().getClassName()); jspServlet.addInitParameter("fork", "false"); - for (Entry initParameter : getJsp().getInitParameters() - .entrySet()) { - jspServlet.addInitParameter(initParameter.getKey(), initParameter.getValue()); - } + getJsp().getInitParameters().forEach(jspServlet::addInitParameter); jspServlet.setLoadOnStartup(3); context.addChild(jspServlet); context.addServletMappingDecoded("*.jsp", "jsp"); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/FileSessionPersistence.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/FileSessionPersistence.java index 0b02f73411..136546600a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/FileSessionPersistence.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/FileSessionPersistence.java @@ -69,10 +69,8 @@ class FileSessionPersistence implements SessionPersistenceManager { private void save(Map sessionData, ObjectOutputStream stream) throws IOException { Map session = new LinkedHashMap<>(); - for (Map.Entry entry : sessionData.entrySet()) { - session.put(entry.getKey(), - new SerializablePersistentSession(entry.getValue())); - } + sessionData.forEach((key, value) -> + session.put(key, new SerializablePersistentSession(value))); stream.writeObject(session); } @@ -104,13 +102,12 @@ class FileSessionPersistence implements SessionPersistenceManager { Map session = readSession(stream); long time = System.currentTimeMillis(); Map result = new LinkedHashMap<>(); - for (Map.Entry entry : session - .entrySet()) { - PersistentSession entrySession = entry.getValue().getPersistentSession(); + session.forEach((key, value) -> { + PersistentSession entrySession = value.getPersistentSession(); if (entrySession.getExpiration().getTime() > time) { - result.put(entry.getKey(), entrySession); + result.put(key, entrySession); } - } + }); return result; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java index f756e5997c..11372b07e1 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java @@ -20,15 +20,12 @@ import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; -import java.nio.charset.Charset; import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; -import java.util.Locale; -import java.util.Map; import java.util.Set; import javax.servlet.ServletContainerInitializer; @@ -331,11 +328,8 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac } private void addLocaleMappings(DeploymentInfo deployment) { - for (Map.Entry entry : getLocaleCharsetMappings().entrySet()) { - Locale locale = entry.getKey(); - Charset charset = entry.getValue(); - deployment.addLocaleCharsetMapping(locale.toString(), charset.toString()); - } + getLocaleCharsetMappings().forEach((locale, charset) -> + deployment.addLocaleCharsetMapping(locale.toString(), charset.toString())); } private void registerServletContainerInitializerToDriveServletContextInitializers( diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java index 68df3bf7eb..f1b4f2c0c8 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java @@ -244,9 +244,7 @@ public final class MimeMappings implements Iterable { public MimeMappings(Map mappings) { Assert.notNull(mappings, "Mappings must not be null"); this.map = new LinkedHashMap<>(); - for (Map.Entry entry : mappings.entrySet()) { - add(entry.getKey(), entry.getValue()); - } + mappings.forEach(this::add); } /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java index 38e82103c2..3bcb1d4a81 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java @@ -79,11 +79,10 @@ public class ServletContextInitializerBeans addServletContextInitializerBeans(beanFactory); addAdaptableBeans(beanFactory); List sortedInitializers = new ArrayList<>(); - for (Map.Entry> entry : this.initializers - .entrySet()) { - AnnotationAwareOrderComparator.sort(entry.getValue()); - sortedInitializers.addAll(entry.getValue()); - } + this.initializers.values().forEach(contextInitializers -> { + AnnotationAwareOrderComparator.sort(contextInitializers); + sortedInitializers.addAll(contextInitializers); + }); this.sortedList = Collections.unmodifiableList(sortedInitializers); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java index 4284ab47b5..cdcd6666ba 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContext.java @@ -384,12 +384,12 @@ public class ServletWebServerApplicationContext extends GenericWebApplicationCon } public void restore() { - for (Map.Entry entry : this.scopes.entrySet()) { + this.scopes.forEach((key, value) -> { if (logger.isInfoEnabled()) { - logger.info("Restoring user defined scope " + entry.getKey()); + logger.info("Restoring user defined scope " + key); } - this.beanFactory.registerScope(entry.getKey(), entry.getValue()); - } + this.beanFactory.registerScope(key, value); + }); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/SystemEnvironmentPropertySourceEnvironmentPostProcessorTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/SystemEnvironmentPropertySourceEnvironmentPostProcessorTests.java index 4b06e5908b..9f410b55ae 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/SystemEnvironmentPropertySourceEnvironmentPostProcessorTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/SystemEnvironmentPropertySourceEnvironmentPostProcessorTests.java @@ -66,12 +66,12 @@ public class SystemEnvironmentPropertySourceEnvironmentPostProcessorTests { .getPropertySources().get("systemEnvironment"); Map originalMap = (Map) original.getSource(); Map replacedMap = replaced.getSource(); - for (Map.Entry entry : originalMap.entrySet()) { - Object actual = replacedMap.get(entry.getKey()); - assertThat(actual).isEqualTo(entry.getValue()); - assertThat(replaced.getOrigin(entry.getKey())) + originalMap.forEach((key, value) -> { + Object actual = replacedMap.get(key); + assertThat(actual).isEqualTo(value); + assertThat(replaced.getOrigin(key)) .isInstanceOf(SystemEnvironmentOrigin.class); - } + }); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java index 2c08350abb..b17cea6b49 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java @@ -44,8 +44,6 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.Locale; import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.zip.GZIPInputStream; @@ -866,12 +864,9 @@ public abstract class AbstractServletWebServerFactoryTests { AbstractServletWebServerFactory factory = getFactory(); this.webServer = factory.getWebServer(); Map configuredMimeMappings = getActualMimeMappings(); - Set> entrySet = configuredMimeMappings.entrySet(); Collection expectedMimeMappings = getExpectedMimeMappings(); - for (Entry entry : entrySet) { - assertThat(expectedMimeMappings) - .contains(new MimeMappings.Mapping(entry.getKey(), entry.getValue())); - } + configuredMimeMappings.forEach((key, value) -> assertThat(expectedMimeMappings). + contains(new MimeMappings.Mapping(key, value))); for (MimeMappings.Mapping mapping : expectedMimeMappings) { assertThat(configuredMimeMappings).containsEntry(mapping.getExtension(), mapping.getMimeType()); From 78534a753db33c21f779e477adba0b8614dddcab Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 19 Mar 2018 08:00:36 -0400 Subject: [PATCH 2/2] Polish "Iterate map by using lambda function" See gh-12528 --- .../health/AbstractHealthAggregator.java | 4 ++-- ...udFoundryVcapEnvironmentPostProcessor.java | 22 +++++++++---------- .../jetty/JettyServletWebServerFactory.java | 4 ++-- .../tomcat/TomcatServletWebServerFactory.java | 5 +++-- .../undertow/FileSessionPersistence.java | 6 ++--- .../UndertowServletWebServerFactory.java | 4 ++-- .../boot/web/server/MimeMappings.java | 2 +- .../ServletContextInitializerBeans.java | 2 +- ...tySourceEnvironmentPostProcessorTests.java | 2 +- 9 files changed, 26 insertions(+), 25 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthAggregator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthAggregator.java index 6b689e03c8..a4f67bd573 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthAggregator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthAggregator.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ public abstract class AbstractHealthAggregator implements HealthAggregator { @Override public final Health aggregate(Map healths) { List statusCandidates = new ArrayList<>(); - healths.values().forEach(health -> statusCandidates.add(health.getStatus())); + healths.values().forEach((health) -> statusCandidates.add(health.getStatus())); Status status = aggregateStatus(statusCandidates); Map details = aggregateDetails(healths); return new Health.Builder(status, details).build(); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java index a6b5c4f9d3..200fad0c62 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -196,39 +196,39 @@ public class CloudFoundryVcapEnvironmentPostProcessor @SuppressWarnings("unchecked") private void flatten(Properties properties, Map input, String path) { - input.forEach((entryKey, value) -> { - String key = getFullKey(path, entryKey); + input.forEach((key, value) -> { + String name = getPropertyName(path, key); if (value instanceof Map) { // Need a compound key - flatten(properties, (Map) value, key); + flatten(properties, (Map) value, name); } else if (value instanceof Collection) { // Need a compound key Collection collection = (Collection) value; - properties.put(key, + properties.put(name, StringUtils.collectionToCommaDelimitedString(collection)); int count = 0; for (Object item : collection) { String itemKey = "[" + (count++) + "]"; - flatten(properties, Collections.singletonMap(itemKey, item), key); + flatten(properties, Collections.singletonMap(itemKey, item), name); } } else if (value instanceof String) { - properties.put(key, value); + properties.put(name, value); } else if (value instanceof Number) { - properties.put(key, value.toString()); + properties.put(name, value.toString()); } else if (value instanceof Boolean) { - properties.put(key, value.toString()); + properties.put(name, value.toString()); } else { - properties.put(key, value == null ? "" : value); + properties.put(name, value == null ? "" : value); } }); } - private String getFullKey(String path, String key) { + private String getPropertyName(String path, String key) { if (!StringUtils.hasText(path)) { return key; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java index 7d44b8340b..8bb8581689 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java @@ -246,8 +246,8 @@ public class JettyServletWebServerFactory extends AbstractServletWebServerFactor } private void addLocaleMappings(WebAppContext context) { - getLocaleCharsetMappings().forEach((locale, charset) -> - context.addLocaleEncoding(locale.toString(), charset.toString())); + getLocaleCharsetMappings().forEach((locale, charset) -> context + .addLocaleEncoding(locale.toString(), charset.toString())); } private File getTempDirectory() { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactory.java index 7913b40474..e2ed862799 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactory.java @@ -232,8 +232,9 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto } private void addLocaleMappings(TomcatEmbeddedContext context) { - getLocaleCharsetMappings().forEach((locale, charset) -> - context.addLocaleEncodingMappingParameter(locale.toString(), charset.toString())); + getLocaleCharsetMappings() + .forEach((locale, charset) -> context.addLocaleEncodingMappingParameter( + locale.toString(), charset.toString())); } private void configureTldSkipPatterns(TomcatEmbeddedContext context) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/FileSessionPersistence.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/FileSessionPersistence.java index 136546600a..f95af43583 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/FileSessionPersistence.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/FileSessionPersistence.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,8 +69,8 @@ class FileSessionPersistence implements SessionPersistenceManager { private void save(Map sessionData, ObjectOutputStream stream) throws IOException { Map session = new LinkedHashMap<>(); - sessionData.forEach((key, value) -> - session.put(key, new SerializablePersistentSession(value))); + sessionData.forEach((key, value) -> session.put(key, + new SerializablePersistentSession(value))); stream.writeObject(session); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java index 11372b07e1..4424986e12 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java @@ -328,8 +328,8 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac } private void addLocaleMappings(DeploymentInfo deployment) { - getLocaleCharsetMappings().forEach((locale, charset) -> - deployment.addLocaleCharsetMapping(locale.toString(), charset.toString())); + getLocaleCharsetMappings().forEach((locale, charset) -> deployment + .addLocaleCharsetMapping(locale.toString(), charset.toString())); } private void registerServletContainerInitializerToDriveServletContextInitializers( diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java index f1b4f2c0c8..35c0403c31 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java index 3bcb1d4a81..02396c273c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java @@ -79,7 +79,7 @@ public class ServletContextInitializerBeans addServletContextInitializerBeans(beanFactory); addAdaptableBeans(beanFactory); List sortedInitializers = new ArrayList<>(); - this.initializers.values().forEach(contextInitializers -> { + this.initializers.values().forEach((contextInitializers) -> { AnnotationAwareOrderComparator.sort(contextInitializers); sortedInitializers.addAll(contextInitializers); }); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/SystemEnvironmentPropertySourceEnvironmentPostProcessorTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/SystemEnvironmentPropertySourceEnvironmentPostProcessorTests.java index 9f410b55ae..2d6b3bf171 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/SystemEnvironmentPropertySourceEnvironmentPostProcessorTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/SystemEnvironmentPropertySourceEnvironmentPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.