Skip to content

Commit

Permalink
Review fixes:
Browse files Browse the repository at this point in the history
changed declaration of default values for connection pool

Signed-off-by: Matthias Kaemmer <[email protected]>
  • Loading branch information
mattkaem committed Oct 30, 2023
1 parent 7536dab commit 9c93861
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
package org.eclipse.hono.service.base.jdbc.config;

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

import io.smallrye.config.ConfigMapping;
import io.smallrye.config.ConfigMapping.NamingStrategy;
import io.smallrye.config.WithDefault;

/**
* Configuration properties for a JDBC service.
Expand Down Expand Up @@ -58,28 +58,32 @@ public interface JdbcOptions {
*
* @return The maximum number of connections in the pool.
*/
OptionalInt maximumPoolSize();
@WithDefault("15")
int maximumPoolSize();

/**
* Gets the minimum size of the DB connection pool.
*
* @return The minimum number of connections in the pool.
*/
OptionalInt minimumPoolSize();
@WithDefault("3")
int minimumPoolSize();

/**
* Gets the initial size of the DB connection pool.
*
* @return The initial number of connections in the pool.
*/
OptionalInt initialPoolSize();
@WithDefault("3")
int initialPoolSize();

/**
* Gets the maximum idle time of connections in the DB connection pool.
*
* @return The maximum idle time of connections in the pool.
*/
OptionalInt maximumIdleTime();
@WithDefault("3600")
int maximumIdleTime();

/**
* Gets the name of the table that contains the data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
public class JdbcProperties {

private static final Logger log = LoggerFactory.getLogger(JdbcProperties.class);
private static final Integer MAXIMUM_POOL_SIZE_DEFAULT = 15;
private static final Integer MINIMUM_POOL_SIZE_DEFAULT = 3;
private static final Integer INITIAL_POOL_SIZE_DEFAULT = 3;
private static final Integer MAXIMUM_IDLE_TIME_DEFAULT = 3600;

private String url;
private String driverClass;
Expand Down Expand Up @@ -63,10 +59,10 @@ public JdbcProperties() {
public JdbcProperties(final JdbcOptions options) {
Objects.requireNonNull(options);
setDriverClass(options.driverClass());
options.maximumPoolSize().ifPresentOrElse(this::setMaximumPoolSize, () -> setMaximumPoolSize(MAXIMUM_POOL_SIZE_DEFAULT));
options.minimumPoolSize().ifPresentOrElse(this::setMinimumPoolSize, () -> setMinimumPoolSize(MINIMUM_POOL_SIZE_DEFAULT));
options.initialPoolSize().ifPresentOrElse(this::setInitialPoolSize, () -> setInitialPoolSize(INITIAL_POOL_SIZE_DEFAULT));
options.maximumIdleTime().ifPresentOrElse(this::setMaximumIdleTime, () -> setMaximumIdleTime(MAXIMUM_IDLE_TIME_DEFAULT));
setMaximumPoolSize(options.maximumPoolSize());
setMinimumPoolSize(options.minimumPoolSize());
setInitialPoolSize(options.initialPoolSize());
setMaximumIdleTime(options.maximumIdleTime());
options.password().ifPresent(this::setPassword);
options.tableName().ifPresent(this::setTableName);
setUrl(options.url());
Expand Down

0 comments on commit 9c93861

Please sign in to comment.