From a49798bc1e9d9db88641bd6be2c93647ed256cd0 Mon Sep 17 00:00:00 2001 From: Thomas Segismont Date: Wed, 27 May 2020 17:04:54 +0200 Subject: [PATCH 1/2] Reactive datasource config: cache-prepared-statements is not specific to any DB Fixes #9642 --- .../runtime/DataSourceReactiveRuntimeConfig.java | 6 ++++++ .../client/runtime/DataSourceReactiveMySQLConfig.java | 3 +++ .../runtime/LegacyDataSourceReactiveMySQLConfig.java | 6 +++--- .../reactive/mysql/client/runtime/MySQLPoolRecorder.java | 9 +++++++++ .../runtime/DataSourceReactivePostgreSQLConfig.java | 3 +++ .../LegacyDataSourceReactivePostgreSQLConfig.java | 4 ++-- .../reactive/pg/client/runtime/PgPoolRecorder.java | 8 ++++++++ 7 files changed, 34 insertions(+), 5 deletions(-) diff --git a/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java b/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java index b9092a9405061..709d06a23dcaf 100644 --- a/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java +++ b/extensions/reactive-datasource/runtime/src/main/java/io/quarkus/reactive/datasource/runtime/DataSourceReactiveRuntimeConfig.java @@ -17,6 +17,12 @@ @ConfigRoot(name = "datasource.reactive", phase = ConfigPhase.RUN_TIME) public class DataSourceReactiveRuntimeConfig { + /** + * Whether prepared statements should be cached on the client side. + */ + @ConfigItem(defaultValue = "false") + public boolean cachePreparedStatements; + /** * The datasource URL. */ diff --git a/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/DataSourceReactiveMySQLConfig.java b/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/DataSourceReactiveMySQLConfig.java index 6f3bd3688a311..e109c2f581843 100644 --- a/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/DataSourceReactiveMySQLConfig.java +++ b/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/DataSourceReactiveMySQLConfig.java @@ -12,8 +12,11 @@ public class DataSourceReactiveMySQLConfig { /** * Whether prepared statements should be cached on the client side. + * + * @deprecated use {@code datasource.reactive.cache-prepared-statements} instead. */ @ConfigItem + @Deprecated public Optional cachePreparedStatements; /** diff --git a/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/LegacyDataSourceReactiveMySQLConfig.java b/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/LegacyDataSourceReactiveMySQLConfig.java index b103aaacd8bfb..d13c790e97b86 100644 --- a/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/LegacyDataSourceReactiveMySQLConfig.java +++ b/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/LegacyDataSourceReactiveMySQLConfig.java @@ -11,21 +11,21 @@ public class LegacyDataSourceReactiveMySQLConfig { /** - * @deprecated use quarkus.datasource.reactive.mysql.cache-prepared-statements instead. + * @deprecated use {@code quarkus.datasource.reactive.cache-prepared-statements} instead. */ @ConfigItem @Deprecated public Optional cachePreparedStatements; /** - * @deprecated use quarkus.datasource.reactive.mysql.charset instead. + * @deprecated use {@code quarkus.datasource.reactive.mysql.charset} instead. */ @ConfigItem @Deprecated public Optional charset; /** - * @deprecated use quarkus.datasource.reactive.mysql.collation instead. + * @deprecated use {@code quarkus.datasource.reactive.mysql.collation} instead. */ @ConfigItem @Deprecated diff --git a/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java b/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java index d0926fda274e6..1358ea23086ac 100644 --- a/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java +++ b/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java @@ -11,6 +11,8 @@ import java.util.Map; +import org.jboss.logging.Logger; + import io.quarkus.arc.runtime.BeanContainer; import io.quarkus.credentials.CredentialsProvider; import io.quarkus.credentials.runtime.CredentialsProviderFinder; @@ -30,6 +32,9 @@ @Recorder @SuppressWarnings("deprecation") public class MySQLPoolRecorder { + + private static final Logger log = Logger.getLogger(MySQLPoolRecorder.class); + public RuntimeValue configureMySQLPool(RuntimeValue vertx, BeanContainer container, DataSourcesRuntimeConfig dataSourcesRuntimeConfig, DataSourceReactiveRuntimeConfig dataSourceReactiveRuntimeConfig, @@ -119,8 +124,12 @@ private MySQLConnectOptions toMySQLConnectOptions(DataSourceRuntimeConfig dataSo } if (dataSourceReactiveMySQLConfig.cachePreparedStatements.isPresent()) { + log.warn("cache-prepared-statements is not specific to a database kind, configure it at the parent level"); mysqlConnectOptions.setCachePreparedStatements(dataSourceReactiveMySQLConfig.cachePreparedStatements.get()); + } else { + mysqlConnectOptions.setCachePreparedStatements(dataSourceReactiveRuntimeConfig.cachePreparedStatements); } + if (dataSourceReactiveMySQLConfig.charset.isPresent()) { mysqlConnectOptions.setCharset(dataSourceReactiveMySQLConfig.charset.get()); } diff --git a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/DataSourceReactivePostgreSQLConfig.java b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/DataSourceReactivePostgreSQLConfig.java index a1748ff6ec047..b1dd120d5a81e 100644 --- a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/DataSourceReactivePostgreSQLConfig.java +++ b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/DataSourceReactivePostgreSQLConfig.java @@ -13,8 +13,11 @@ public class DataSourceReactivePostgreSQLConfig { /** * Whether prepared statements should be cached on the client side. + * + * @deprecated use {@code datasource.reactive.cache-prepared-statements} instead. */ @ConfigItem + @Deprecated public Optional cachePreparedStatements; /** diff --git a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/LegacyDataSourceReactivePostgreSQLConfig.java b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/LegacyDataSourceReactivePostgreSQLConfig.java index cbfe8787bcdac..e28965a7d643e 100644 --- a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/LegacyDataSourceReactivePostgreSQLConfig.java +++ b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/LegacyDataSourceReactivePostgreSQLConfig.java @@ -12,14 +12,14 @@ public class LegacyDataSourceReactivePostgreSQLConfig { /** - * @deprecated use quarkus.datasource.reactive.postgresql.cache-prepared-statements instead. + * @deprecated use {@code quarkus.datasource.reactive.cache-prepared-statements} instead. */ @ConfigItem @Deprecated public Optional cachePreparedStatements; /** - * @deprecated use quarkus.datasource.reactive.postgresql.pipelining-limit instead. + * @deprecated use {@code quarkus.datasource.reactive.postgresql.pipelining-limit} instead. */ @ConfigItem @Deprecated diff --git a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java index b6adc5c95c24d..00bbeb2aa0afc 100644 --- a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java +++ b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java @@ -11,6 +11,8 @@ import java.util.Map; +import org.jboss.logging.Logger; + import io.quarkus.arc.runtime.BeanContainer; import io.quarkus.credentials.CredentialsProvider; import io.quarkus.credentials.runtime.CredentialsProviderFinder; @@ -31,6 +33,8 @@ @SuppressWarnings("deprecation") public class PgPoolRecorder { + private static final Logger log = Logger.getLogger(PgPoolRecorder.class); + public RuntimeValue configurePgPool(RuntimeValue vertx, BeanContainer container, DataSourcesRuntimeConfig dataSourcesRuntimeConfig, DataSourceReactiveRuntimeConfig dataSourceReactiveRuntimeConfig, @@ -121,8 +125,12 @@ private PgConnectOptions toPgConnectOptions(DataSourceRuntimeConfig dataSourceRu } if (dataSourceReactivePostgreSQLConfig.cachePreparedStatements.isPresent()) { + log.warn("cache-prepared-statements is not specific to a database kind, configure it at the parent level"); pgConnectOptions.setCachePreparedStatements(dataSourceReactivePostgreSQLConfig.cachePreparedStatements.get()); + } else { + pgConnectOptions.setCachePreparedStatements(dataSourceReactiveRuntimeConfig.cachePreparedStatements); } + if (dataSourceReactivePostgreSQLConfig.pipeliningLimit.isPresent()) { pgConnectOptions.setPipeliningLimit(dataSourceReactivePostgreSQLConfig.pipeliningLimit.getAsInt()); } From 93b91ebd68c9a1bbce4701f0e8a81b6d2332e079 Mon Sep 17 00:00:00 2001 From: Thomas Segismont Date: Mon, 22 Jun 2020 11:27:13 +0200 Subject: [PATCH 2/2] Better warning message --- .../reactive/mysql/client/runtime/MySQLPoolRecorder.java | 2 +- .../io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java b/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java index 1358ea23086ac..a9bd951745545 100644 --- a/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java +++ b/extensions/reactive-mysql-client/runtime/src/main/java/io/quarkus/reactive/mysql/client/runtime/MySQLPoolRecorder.java @@ -124,7 +124,7 @@ private MySQLConnectOptions toMySQLConnectOptions(DataSourceRuntimeConfig dataSo } if (dataSourceReactiveMySQLConfig.cachePreparedStatements.isPresent()) { - log.warn("cache-prepared-statements is not specific to a database kind, configure it at the parent level"); + log.warn("datasource.reactive.mysql.cache-prepared-statements is deprecated, use datasource.reactive.cache-prepared-statements instead"); mysqlConnectOptions.setCachePreparedStatements(dataSourceReactiveMySQLConfig.cachePreparedStatements.get()); } else { mysqlConnectOptions.setCachePreparedStatements(dataSourceReactiveRuntimeConfig.cachePreparedStatements); diff --git a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java index 00bbeb2aa0afc..6dc0df3e29ecf 100644 --- a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java +++ b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java @@ -125,7 +125,7 @@ private PgConnectOptions toPgConnectOptions(DataSourceRuntimeConfig dataSourceRu } if (dataSourceReactivePostgreSQLConfig.cachePreparedStatements.isPresent()) { - log.warn("cache-prepared-statements is not specific to a database kind, configure it at the parent level"); + log.warn("datasource.reactive.postgresql.cache-prepared-statements is deprecated, use datasource.reactive.cache-prepared-statements instead"); pgConnectOptions.setCachePreparedStatements(dataSourceReactivePostgreSQLConfig.cachePreparedStatements.get()); } else { pgConnectOptions.setCachePreparedStatements(dataSourceReactiveRuntimeConfig.cachePreparedStatements);