Skip to content

Avoid creation of unnecessary collections #14916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -95,7 +93,7 @@ private RequestMappingInfo withEndpointMappedPatterns(
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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
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;
Expand Down Expand Up @@ -95,7 +94,7 @@ private RequestMappingInfo withEndpointMappedPatterns(
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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
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;
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
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;
Expand All @@ -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;

Expand Down