Skip to content

Commit

Permalink
Merge pull request #21681 from rsvoboda/cleanup.2021-11-24
Browse files Browse the repository at this point in the history
Code cleanup with small performance improvements
  • Loading branch information
geoand authored Nov 25, 2021
2 parents bd87966 + ab1c2ed commit e6ffbe4
Show file tree
Hide file tree
Showing 30 changed files with 25 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import java.util.Optional;

import com.amazonaws.services.lambda.runtime.events.APIGatewayV2HTTPEvent;

import io.quarkus.amazon.lambda.http.model.AwsProxyRequest;
import io.quarkus.security.identity.AuthenticationRequestContext;
import io.quarkus.security.identity.IdentityProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ private IndexView buildApplicationIndex(ArcConfig config, ApplicationArchivesBui
.initBeanDefiningAnnotations(additionalBeanDefiningAnnotations.stream()
.map(bda -> new BeanDefiningAnnotation(bda.getName(), bda.getDefaultScope()))
.collect(Collectors.toList()), stereotypes);
for (DotName customScopeAnnotationName : customScopes.getCustomScopeNames()) {
beanDefiningAnnotations.add(customScopeAnnotationName);
}
beanDefiningAnnotations.addAll(customScopes.getCustomScopeNames());
// Also include archives that are not bean archives but contain qualifiers or interceptor bindings
beanDefiningAnnotations.add(DotNames.QUALIFIER);
beanDefiningAnnotations.add(DotNames.INTERCEPTOR_BINDING);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.quarkus.elasticsearch.restclient.common.runtime.graal;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -57,8 +55,7 @@ public synchronized void setNodes(Collection<Node> nodes) {
nodesByHost.put(node.getHost(), node);
authCache.put(node.getHost(), new BasicScheme());
}
this.nodeTuple = new NodeTuple<>(Collections.unmodifiableList(new ArrayList<>(nodesByHost.values())),
authCache);
this.nodeTuple = new NodeTuple<>(List.copyOf(nodesByHost.values()), authCache);
this.blacklist.clear();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,7 @@ private void processCloudEvent(RoutingContext routingContext) {
responseEvent.put(dsName, outputCloudEvent.dataSchema());
}

outputCloudEvent.extensions()
.entrySet()
.forEach(e -> responseEvent.put(e.getKey(), e.getValue()));
responseEvent.putAll(outputCloudEvent.extensions());

String dataContentType = outputCloudEvent.dataContentType();
if (dataContentType != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import org.hibernate.MappingException;
import org.hibernate.SessionFactory;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.SessionFactoryBuilder;
import org.hibernate.boot.internal.MetadataImpl;
import org.hibernate.boot.internal.SessionFactoryOptionsBuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.quarkus.infinispan.client.deployment.devservices;

import java.util.Objects;
import java.util.Optional;
import java.util.OptionalInt;

import io.quarkus.runtime.annotations.ConfigGroup;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.quarkus.jdbc.mariadb.runtime.graal;

import org.mariadb.jdbc.internal.io.socket.SocketHandlerFunction;
import org.mariadb.jdbc.internal.util.Utils;

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.RecomputeFieldValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.quarkus.kubernetes.config.deployment;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.jboss.logmanager.Level;

Expand Down Expand Up @@ -43,7 +43,7 @@ public void handleAccessToSecrets(KubernetesConfigSourceConfig config,
new KubernetesRoleBuildItem.PolicyRule(
Collections.singletonList(""),
Collections.singletonList("secrets"),
Arrays.asList("get")))));
List.of("get")))));
roleBindingProducer.produce(new KubernetesRoleBindingBuildItem("view-secrets", false));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.quarkus.kubernetes.deployment;

import static io.quarkus.kubernetes.deployment.Constants.MINIKUBE;

import java.util.Optional;

import io.dekorate.AbstractKubernetesManifestGenerator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import io.quarkus.micrometer.runtime.config.runtime.HttpClientConfig;
import io.quarkus.micrometer.runtime.config.runtime.HttpServerConfig;
import io.quarkus.micrometer.runtime.config.runtime.VertxConfig;
import io.quarkus.vertx.http.deployment.FilterBuildItem;

/**
* Avoid directly referencing optional dependencies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.quarkus.micrometer.runtime.binder.mpmetrics;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

Expand Down Expand Up @@ -68,7 +67,7 @@ Tag[] convertTags() {
}

public String toString() {
return name + Arrays.asList(tags);
return name + List.of(tags);
}

// Deal with ubiquitous MetricID containing nefarious TreeSet and arbitrary
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.quarkus.micrometer.runtime.binder.mpmetrics;

import java.util.*;

import javax.enterprise.inject.Produces;
import javax.inject.Singleton;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.lang.reflect.Field;
import java.util.Collections;
import java.util.Map;
import java.util.Properties;

import org.jboss.logging.Logger;
Expand Down Expand Up @@ -38,9 +37,7 @@ public void setNodeName(final TransactionManagerConfiguration transactions) {
public void setDefaultProperties(Properties properties) {
//TODO: this is a huge hack to avoid loading XML parsers
//this needs a proper SPI
for (Map.Entry<Object, Object> i : System.getProperties().entrySet()) {
properties.put(i.getKey(), i.getValue());
}
properties.putAll(System.getProperties());

try {
Field field = PropertiesFactory.class.getDeclaredField("delegatePropertiesFactory");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.nio.file.attribute.FileTime;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -586,15 +585,15 @@ private ClientRepresentation createClient(String clientId, String oidcClientSecr
ClientRepresentation client = new ClientRepresentation();

client.setClientId(clientId);
client.setRedirectUris(Arrays.asList("*"));
client.setRedirectUris(List.of("*"));
client.setPublicClient(false);
client.setSecret(oidcClientSecret);
client.setDirectAccessGrantsEnabled(true);
client.setServiceAccountsEnabled(true);
client.setImplicitFlowEnabled(true);
client.setEnabled(true);
client.setRedirectUris(Arrays.asList("*"));
client.setDefaultClientScopes(Arrays.asList("microprofile-jwt"));
client.setRedirectUris(List.of("*"));
client.setDefaultClientScopes(List.of("microprofile-jwt"));

return client;
}
Expand All @@ -605,7 +604,7 @@ private UserRepresentation createUser(String username, String password, String..
user.setUsername(username);
user.setEnabled(true);
user.setCredentials(new ArrayList<>());
user.setRealmRoles(Arrays.asList(realmRoles));
user.setRealmRoles(List.of(realmRoles));

CredentialRepresentation credential = new CredentialRepresentation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import javax.enterprise.context.ApplicationScoped;
Expand All @@ -20,7 +19,7 @@ public class TestSpanExporter implements SpanExporter {

public List<SpanData> getFinishedSpanItems() {
synchronized (this) {
return Collections.unmodifiableList(new ArrayList<>(finishedSpanItems));
return List.copyOf(finishedSpanItems);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ private static boolean deleteOnCascadeDetected(AbstractJpaOperations<?> jpaOpera
boolean doCascade = Arrays.stream(propertyCascadeStyles)
.anyMatch(cascadeStyle -> cascadeStyle.doCascade(CascadingActions.DELETE));
boolean hasElementCollection = declaredAttributes.stream()
.filter(attribute -> attribute.getPersistentAttributeType()
.equals(Attribute.PersistentAttributeType.ELEMENT_COLLECTION))
.count() > 0;
.anyMatch(attribute -> attribute.getPersistentAttributeType()
.equals(Attribute.PersistentAttributeType.ELEMENT_COLLECTION));
return doCascade || hasElementCollection;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import io.quarkus.rest.data.panache.deployment.ResourceMetadata;
import io.quarkus.rest.data.panache.deployment.properties.ResourceProperties;
import io.quarkus.rest.data.panache.deployment.utils.ResponseImplementor;
import io.quarkus.rest.data.panache.runtime.hal.HalEntityWrapper;

public final class GetHalMethodImplementor extends HalMethodImplementor {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.quarkus.vertx.web.runtime.devmode;

import static io.quarkus.runtime.TemplateHtmlBuilder.adjustRoot;

import java.util.List;

import io.quarkus.runtime.TemplateHtmlBuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.quarkus.resteasy.common.spi;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -55,8 +53,7 @@ public final class ResteasyDotNames {
public static final DotName JSONB_TRANSIENT = DotName.createSimple("javax.json.bind.annotation.JsonbTransient");
public static final DotName XML_TRANSIENT = DotName.createSimple("javax.xml.bind.annotation.XmlTransient");

public static final List<DotName> JAXRS_METHOD_ANNOTATIONS = Collections
.unmodifiableList(Arrays.asList(GET, POST, HEAD, DELETE, PUT, PATCH, OPTIONS));
public static final List<DotName> JAXRS_METHOD_ANNOTATIONS = List.of(GET, POST, HEAD, DELETE, PUT, PATCH, OPTIONS);

public static final IgnoreTypeForReflectionPredicate IGNORE_TYPE_FOR_REFLECTION_PREDICATE = new IgnoreTypeForReflectionPredicate();
public static final IgnoreFieldForReflectionPredicate IGNORE_FIELD_FOR_REFLECTION_PREDICATE = new IgnoreFieldForReflectionPredicate();
Expand Down Expand Up @@ -101,7 +98,7 @@ public boolean test(MethodInfo methodInfo) {
}

// Types ignored for reflection used by the RESTEasy and SmallRye REST client extensions.
private static final Set<DotName> TYPES_IGNORED_FOR_REFLECTION = new HashSet<>(Arrays.asList(
private static final Set<DotName> TYPES_IGNORED_FOR_REFLECTION = new HashSet<>(List.of(
// Consider adding packages below instead if it makes more sense
));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.quarkus.resteasy.reactive.common.runtime;

import java.util.List;
import java.util.Optional;

import io.quarkus.runtime.annotations.ConfigItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Singleton;

import org.jboss.jandex.AnnotationInstance;
Expand Down Expand Up @@ -37,7 +36,6 @@
import io.quarkus.gizmo.MethodDescriptor;
import io.quarkus.gizmo.ResultHandle;
import io.quarkus.runtime.util.HashUtil;
import io.quarkus.vertx.http.runtime.CurrentVertxRequest;

final class CustomResourceProducersGenerator {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.quarkus.security.deployment;

import static io.quarkus.security.deployment.SecurityTransformerUtils.DENY_ALL;
import static io.quarkus.security.deployment.SecurityTransformerUtils.hasStandardSecurityAnnotation;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ public List<DevChannelInfo> get() {

// Unfortunately, there is no easy way to obtain the connectors metadata
Connectors connectors = container.instance(Connectors.class).get();
for (Entry<String, Component> entry : connectors.outgoingConnectors.entrySet()) {
publishers.put(entry.getKey(), entry.getValue());
}
publishers.putAll(connectors.outgoingConnectors);
for (Entry<String, Component> entry : connectors.incomingConnectors.entrySet()) {
consumers.computeIfAbsent(entry.getKey(), fun)
.add(entry.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public class SpringCacheProcessor {
static final DotName CACHE_PUT = DotName.createSimple(CachePut.class.getName());
static final DotName CACHE_EVICT = DotName.createSimple(CacheEvict.class.getName());

private static final List<DotName> CACHE_ANNOTATIONS = Collections
.unmodifiableList(Arrays.asList(CACHEABLE, CACHE_PUT, CACHE_EVICT));
private static final List<DotName> CACHE_ANNOTATIONS = List.of(CACHEABLE, CACHE_PUT, CACHE_EVICT);

// some of these restrictions can probably be lifted by us doing additional work on caching after https://github.com/quarkusio/quarkus/pull/8631 lands
private static final Set<String> CURRENTLY_UNSUPPORTED_ANNOTATION_VALUES = Collections
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URL;
import java.sql.Blob;
import java.sql.NClob;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private FilterBuildItem(Builder builder) {
this.filterClass = builder.filterClass;
this.loadOnStartup = builder.loadOnStartup;
this.asyncSupported = builder.asyncSupported;
this.mappings = Collections.unmodifiableList(new ArrayList<>(builder.mappings));
this.mappings = List.copyOf(builder.mappings);
this.instanceFactory = builder.instanceFactory;
this.initParams = Collections.unmodifiableMap(new HashMap<>(builder.initParams));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private ServletBuildItem(Builder builder) {
this.servletClass = builder.servletClass;
this.loadOnStartup = builder.loadOnStartup;
this.asyncSupported = builder.asyncSupported;
this.mappings = Collections.unmodifiableList(new ArrayList<>(builder.mappings));
this.mappings = List.copyOf(builder.mappings);
this.instanceFactory = builder.instanceFactory;
this.initParams = Collections.unmodifiableMap(new HashMap<>(builder.initParams));
this.multipartConfig = builder.multipartConfig;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.quarkus.vault.runtime.config;

import java.util.Arrays;
import java.util.List;

import org.eclipse.microprofile.config.spi.ConfigSource;
import org.eclipse.microprofile.config.spi.ConfigSourceProvider;
Expand All @@ -18,6 +18,6 @@ public VaultConfigSourceProvider(VaultBootstrapConfig vaultBootstrapConfig) {

@Override
public Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader) {
return Arrays.asList(new VaultConfigSource(vaultBootstrapConfig));
return List.of(new VaultConfigSource(vaultBootstrapConfig));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public VersionRangeResult resolveVersionRange(RepositorySystemSession session,
this.versionRangeResolver = versionRangeResolver;
this.remoteRepositoryManager = remoteRepositoryManager;
this.repositories = repositories;
this.externalRepositories = Collections.unmodifiableList(new ArrayList<>(repositories));
this.externalRepositories = List.copyOf(repositories);
this.repositoryIds = new HashSet<>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import io.quarkus.devtools.codestarts.CodestartResource;
import io.quarkus.devtools.codestarts.CodestartResource.Source;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand All @@ -13,10 +11,10 @@ public interface CodestartFileReader {

CodestartFileReader DEFAULT = new DefaultCodestartFileReader();

List<CodestartFileReader> ALL = Collections.unmodifiableList(Arrays.asList(
List<CodestartFileReader> ALL = List.of(
DEFAULT,
new QuteCodestartFileReader(),
new IgnoreCodestartFileReader()));
new IgnoreCodestartFileReader());

boolean matches(String fileName);

Expand Down

0 comments on commit e6ffbe4

Please sign in to comment.