Avoid creation of unnecessary collections

Closes gh-14916
pull/16246/head
dreis2211 6 years ago committed by Madhura Bhave
parent 35221c1142
commit 5c0d7f4ac0

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

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

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

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

Loading…
Cancel
Save