Merge pull request #14916 from dreis2211

* gh-14916:
  Avoid creation of unnecessary collections
pull/16246/head
Madhura Bhave 6 years ago
commit 5742c2383c

@ -17,10 +17,8 @@
package org.springframework.boot.actuate.endpoint.web.reactive; package org.springframework.boot.actuate.endpoint.web.reactive;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -95,7 +93,7 @@ public class ControllerEndpointHandlerMapping extends RequestMappingHandlerMappi
ExposableControllerEndpoint endpoint, RequestMappingInfo mapping) { ExposableControllerEndpoint endpoint, RequestMappingInfo mapping) {
Set<PathPattern> patterns = mapping.getPatternsCondition().getPatterns(); Set<PathPattern> patterns = mapping.getPatternsCondition().getPatterns();
if (patterns.isEmpty()) { if (patterns.isEmpty()) {
patterns = new HashSet<>(Arrays.asList(getPathPatternParser().parse(""))); patterns = Collections.singleton(getPathPatternParser().parse(""));
} }
PathPattern[] endpointMappedPatterns = patterns.stream() PathPattern[] endpointMappedPatterns = patterns.stream()
.map((pattern) -> getEndpointMappedPattern(endpoint, pattern)) .map((pattern) -> getEndpointMappedPattern(endpoint, pattern))

@ -19,7 +19,6 @@ package org.springframework.boot.actuate.endpoint.web.servlet;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -95,7 +94,7 @@ public class ControllerEndpointHandlerMapping extends RequestMappingHandlerMappi
ExposableControllerEndpoint endpoint, RequestMappingInfo mapping) { ExposableControllerEndpoint endpoint, RequestMappingInfo mapping) {
Set<String> patterns = mapping.getPatternsCondition().getPatterns(); Set<String> patterns = mapping.getPatternsCondition().getPatterns();
if (patterns.isEmpty()) { if (patterns.isEmpty()) {
patterns = new HashSet<>(Collections.singletonList("")); patterns = Collections.singleton("");
} }
String[] endpointMappedPatterns = patterns.stream() String[] endpointMappedPatterns = patterns.stream()
.map((pattern) -> getEndpointMappedPattern(endpoint, pattern)) .map((pattern) -> getEndpointMappedPattern(endpoint, pattern))

@ -20,9 +20,7 @@ import java.io.FileNotFoundException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.time.Duration; import java.time.Duration;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -97,8 +95,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
static final String LOMBOK_ACCESS_LEVEL_PUBLIC = "PUBLIC"; static final String LOMBOK_ACCESS_LEVEL_PUBLIC = "PUBLIC";
private static final Set<String> SUPPORTED_OPTIONS = Collections.unmodifiableSet( private static final Set<String> SUPPORTED_OPTIONS = Collections
new HashSet<>(Arrays.asList(ADDITIONAL_METADATA_LOCATIONS_OPTION))); .unmodifiableSet(Collections.singleton(ADDITIONAL_METADATA_LOCATIONS_OPTION));
private MetadataStore metadataStore; private MetadataStore metadataStore;

@ -23,9 +23,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -48,7 +46,7 @@ public class DefaultLaunchScript implements LaunchScript {
.compile("\\{\\{(\\w+)(:.*?)?\\}\\}(?!\\})"); .compile("\\{\\{(\\w+)(:.*?)?\\}\\}(?!\\})");
private static final Set<String> FILE_PATH_KEYS = Collections private static final Set<String> FILE_PATH_KEYS = Collections
.unmodifiableSet(new HashSet<>(Arrays.asList("inlinedConfScript"))); .unmodifiableSet(Collections.singleton("inlinedConfScript"));
private final String content; private final String content;

Loading…
Cancel
Save