Skip to content
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

Replace all @ConfigItem of type Optional<Integer> to OptionalInt #10440

Merged
merged 1 commit into from
Jul 4, 2020
Merged
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 @@ -154,7 +154,7 @@ private void validateNettyClientConfig(String extension, NettyHttpClientConfig c
String.format("quarkus.%s.async-client.http2.max-streams may not be negative.", extension));
}

if (config.http2.initialWindowSize.isPresent() && config.http2.initialWindowSize.get() <= 0) {
if (config.http2.initialWindowSize.isPresent() && config.http2.initialWindowSize.getAsInt() <= 0) {
throw new RuntimeConfigurationError(
String.format("quarkus.%s.async-client.http2.initial-window-size may not be negative.", extension));
}
Expand All @@ -165,7 +165,7 @@ private void validateNettyClientConfig(String extension, NettyHttpClientConfig c
extension));
}
if (config.eventLoop.override) {
if (config.eventLoop.numberOfThreads.isPresent() && config.eventLoop.numberOfThreads.get() <= 0) {
if (config.eventLoop.numberOfThreads.isPresent() && config.eventLoop.numberOfThreads.getAsInt() <= 0) {
throw new RuntimeConfigurationError(
String.format("quarkus.%s.async-client.event-loop.number-of-threads may not be negative or zero.",
extension));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.time.Duration;
import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;

import io.netty.handler.ssl.SslProvider;
import io.quarkus.runtime.annotations.ConfigGroup;
Expand Down Expand Up @@ -137,7 +138,7 @@ public static class Http2Config {
* <p>
*/
@ConfigItem(defaultValueDocumentation = "1048576")
public Optional<Integer> initialWindowSize;
public OptionalInt initialWindowSize;

/**
* Sets the period that the Netty client will send {@code PING} frames to the remote endpoint to check the
Expand Down Expand Up @@ -166,7 +167,7 @@ public static class SdkEventLoopGroupConfig {
* `io.netty.eventLoopThreads` system property is set.
*/
@ConfigItem
public Optional<Integer> numberOfThreads;
public OptionalInt numberOfThreads;

/**
* The thread name prefix for threads created by this thread factory used by event loop group.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class GrpcClientConfiguration {
* The flow control window in bytes. Default is 1MiB.
*/
@ConfigItem
public Optional<Integer> flowControlWindow;
public OptionalInt flowControlWindow;

/**
* The duration without ongoing RPCs before going to idle mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.time.Duration;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.OptionalLong;

import io.quarkus.runtime.annotations.ConfigDocSection;
Expand Down Expand Up @@ -285,13 +286,13 @@ public static class HibernateOrmConfigJdbc {
* How many rows are fetched at a time by the JDBC driver.
*/
@ConfigItem
public Optional<Integer> statementFetchSize;
public OptionalInt statementFetchSize;

/**
* The number of updates (inserts, updates and deletes) that are sent by the JDBC driver at one time for execution.
*/
@ConfigItem
public Optional<Integer> statementBatchSize;
public OptionalInt statementBatchSize;

public boolean isAnyPropertySet() {
return timezone.isPresent() || statementFetchSize.isPresent() || statementBatchSize.isPresent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,11 +680,11 @@ private void handleHibernateORMWithNoPersistenceXml(

hibernateConfig.jdbc.statementFetchSize.ifPresent(
fetchSize -> desc.getProperties().setProperty(AvailableSettings.STATEMENT_FETCH_SIZE,
fetchSize.toString()));
String.valueOf(fetchSize)));

hibernateConfig.jdbc.statementBatchSize.ifPresent(
fetchSize -> desc.getProperties().setProperty(AvailableSettings.STATEMENT_BATCH_SIZE,
fetchSize.toString()));
String.valueOf(fetchSize)));

// Logging
if (hibernateConfig.log.sql) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.net.URI;
import java.time.Duration;
import java.util.Optional;
import java.util.OptionalInt;

import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
Expand Down Expand Up @@ -57,7 +58,7 @@ public class JaegerConfig {
* The reporter's maximum queue size
*/
@ConfigItem
public Optional<Integer> reporterMaxQueueSize;
public OptionalInt reporterMaxQueueSize;

/**
* The reporter's flush interval
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkus.jaeger.runtime;

import java.util.Optional;
import java.util.OptionalInt;
import java.util.function.Function;

import org.jboss.logging.Logger;
Expand Down Expand Up @@ -78,4 +79,10 @@ private <T> void initTracerProperty(String property, Optional<T> value, Function
System.setProperty(property, accessor.apply(value.get()));
}
}

private void initTracerProperty(String property, OptionalInt value, Function<Integer, String> accessor) {
if (value.isPresent()) {
System.setProperty(property, accessor.apply(Integer.valueOf(value.getAsInt())));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

package io.quarkus.kubernetes.deployment;

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

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;
Expand All @@ -19,7 +19,7 @@ public class AwsElasticBlockStoreVolumeConfig {
* The partition.
*/
@ConfigItem
Optional<Integer> partition;
OptionalInt partition;

/**
* Filesystem type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalInt;

import io.dekorate.kubernetes.annotation.ImagePullPolicy;
import io.dekorate.kubernetes.annotation.ServiceType;
Expand Down Expand Up @@ -105,7 +106,7 @@ public class KubernetesConfig implements PlatformConfiguration {
* The nodePort to set when serviceType is set to node-port.
*/
@ConfigItem
Optional<Integer> nodePort;
OptionalInt nodePort;

/**
* Image pull policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,8 @@ private void handleServices(Session session, KubernetesConfig kubernetesConfig,
session.resources().decorate(KUBERNETES,
new ApplyServiceTypeDecorator(kubernetesName, kubernetesConfig.getServiceType().name()));
if ((kubernetesConfig.getServiceType() == ServiceType.NodePort) && kubernetesConfig.nodePort.isPresent()) {
session.resources().decorate(KUBERNETES, new AddNodePortDecorator(openshiftName, kubernetesConfig.nodePort.get()));
session.resources().decorate(KUBERNETES,
new AddNodePortDecorator(openshiftName, kubernetesConfig.nodePort.getAsInt()));
}
session.resources().decorate(MINIKUBE,
new ApplyServiceTypeDecorator(kubernetesName, ServiceType.NodePort.name()));
Expand All @@ -643,7 +644,8 @@ private void handleServices(Session session, KubernetesConfig kubernetesConfig,
session.resources().decorate(OPENSHIFT,
new ApplyServiceTypeDecorator(openshiftName, openshiftConfig.getServiceType().name()));
if ((openshiftConfig.getServiceType() == ServiceType.NodePort) && openshiftConfig.nodePort.isPresent()) {
session.resources().decorate(OPENSHIFT, new AddNodePortDecorator(openshiftName, openshiftConfig.nodePort.get()));
session.resources().decorate(OPENSHIFT,
new AddNodePortDecorator(openshiftName, openshiftConfig.nodePort.getAsInt()));
}

session.resources().decorate(KNATIVE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalInt;

import io.dekorate.kubernetes.annotation.ImagePullPolicy;
import io.dekorate.kubernetes.annotation.ServiceType;
Expand Down Expand Up @@ -106,7 +107,7 @@ public class OpenshiftConfig implements PlatformConfiguration {
* The nodePort to set when serviceType is set to nodePort
*/
@ConfigItem
Optional<Integer> nodePort;
OptionalInt nodePort;

/**
* Image pull policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package io.quarkus.kubernetes.deployment;

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

import io.dekorate.kubernetes.annotation.Protocol;
import io.quarkus.runtime.annotations.ConfigGroup;
Expand All @@ -14,13 +15,13 @@ public class PortConfig {
* The port number. Refers to the container port.
*/
@ConfigItem
Optional<Integer> containerPort;
OptionalInt containerPort;

/**
* The host port.
*/
@ConfigItem
Optional<Integer> hostPort;
OptionalInt hostPort;

/**
* The application path (refers to web application path).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalInt;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;
Expand Down Expand Up @@ -618,7 +619,7 @@ public static Token fromAudience(String... audience) {
* number of seconds.
*/
@ConfigItem
public Optional<Integer> lifespanGrace = Optional.empty();
public OptionalInt lifespanGrace = OptionalInt.empty();

/**
* Name of the claim which contains a principal name. By default, the 'upn', 'preferred_username' and `sub` claims are
Expand Down Expand Up @@ -660,12 +661,12 @@ public void setAudience(List<String> audience) {
this.audience = Optional.of(audience);
}

public Optional<Integer> getLifespanGrace() {
public OptionalInt getLifespanGrace() {
return lifespanGrace;
}

public void setLifespanGrace(int lifespanGrace) {
this.lifespanGrace = Optional.of(lifespanGrace);
this.lifespanGrace = OptionalInt.of(lifespanGrace);
}

public Optional<String> getPrincipalClaim() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ private void processSuccessfulAuthentication(RoutingContext context, TenantConfi

long maxAge = result.idToken().getLong("exp") - result.idToken().getLong("iat");
if (configContext.oidcConfig.token.lifespanGrace.isPresent()) {
maxAge += configContext.oidcConfig.token.lifespanGrace.get();
maxAge += configContext.oidcConfig.token.lifespanGrace.getAsInt();
}
createCookie(context, configContext, getSessionCookieName(configContext), cookieValue, maxAge);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private TenantConfigContext createTenantContext(Vertx vertx, OidcTenantConfig oi

if (oidcConfig.getToken().getLifespanGrace().isPresent()) {
JWTOptions jwtOptions = new JWTOptions();
jwtOptions.setLeeway(oidcConfig.getToken().getLifespanGrace().get());
jwtOptions.setLeeway(oidcConfig.getToken().getLifespanGrace().getAsInt());
options.setJWTOptions(jwtOptions);
}

Expand Down