From c4a4640107f36407c0e7c8d53685c88cbbd7bb75 Mon Sep 17 00:00:00 2001 From: Thomas Segismont Date: Tue, 10 May 2022 18:09:04 +0200 Subject: [PATCH 1/3] Dev services: MSSQL reactive client does not support JDBC url format Fixes #25233 The "encrypt" property is not needed anyway, it is the default of both the JDBC and reactive clients. https://docs.microsoft.com/en-us/sql/connect/jdbc/understanding-ssl-support?view=sql-server-ver15#remarks --- ...tasourceConfigurationHandlerBuildItem.java | 41 ++++++++++++++++--- .../reactive-mssql-client/deployment/pom.xml | 5 +++ .../ReactiveMSSQLClientProcessor.java | 12 +++++- .../DevServicesMsSQLDatasourceTestCase.java | 40 ++++++++++++++++++ 4 files changed, 91 insertions(+), 7 deletions(-) create mode 100644 extensions/reactive-mssql-client/deployment/src/test/java/io/quarkus/reactive/mssql/client/DevServicesMsSQLDatasourceTestCase.java diff --git a/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceConfigurationHandlerBuildItem.java b/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceConfigurationHandlerBuildItem.java index 0b246e4a123e6..65a1a1a02138d 100644 --- a/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceConfigurationHandlerBuildItem.java +++ b/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceConfigurationHandlerBuildItem.java @@ -3,6 +3,7 @@ import java.util.Collections; import java.util.Map; import java.util.function.BiFunction; +import java.util.function.Function; import java.util.function.Predicate; import io.quarkus.builder.item.MultiBuildItem; @@ -85,17 +86,31 @@ private static String datasourceURLPropName(String dsName) { } public static DevServicesDatasourceConfigurationHandlerBuildItem reactive(String dbKind) { + return reactive(dbKind, new Function() { + @Override + public String apply(String url) { + return url.replaceFirst("jdbc:", "vertx-reactive:"); + } + }); + } + + public static DevServicesDatasourceConfigurationHandlerBuildItem reactive(String dbKind, + Function jdbcUrlTransformer) { return new DevServicesDatasourceConfigurationHandlerBuildItem(dbKind, new BiFunction>() { @Override public Map apply(String dsName, DevServicesDatasourceProvider.RunningDevServicesDatasource runningDevDb) { + String url = jdbcUrlTransformer.apply(runningDevDb.getUrl()); if (dsName == null) { - return Collections.singletonMap("quarkus.datasource.reactive.url", - runningDevDb.getUrl().replaceFirst("jdbc:", "vertx-reactive:")); + return Collections.singletonMap("quarkus.datasource.reactive.url", url); } else { - return Collections.singletonMap("quarkus.datasource.\"" + dsName + "\".reactive.url", - runningDevDb.getUrl().replaceFirst("jdbc:", "vertx-reactive:")); + // we use quoted and unquoted versions because depending on whether a user configured other JDBC properties + // one of the URLs may be ignored + // see https://github.com/quarkusio/quarkus/issues/21387 + return Map.of( + datasourceReactiveURLPropName(dsName, false), url, + datasourceReactiveURLPropName(dsName, true), url); } } }, new Predicate() { @@ -104,10 +119,24 @@ public boolean test(String dsName) { if (dsName == null) { return ConfigUtils.isPropertyPresent("quarkus.datasource.reactive.url"); } else { - return ConfigUtils.isPropertyPresent("quarkus.datasource.\"" + dsName + "\".reactive.url") || - ConfigUtils.isPropertyPresent("quarkus.datasource." + dsName + ".reactive.url"); + return ConfigUtils.isPropertyPresent(datasourceReactiveURLPropName(dsName, false)) || + ConfigUtils.isPropertyPresent(datasourceReactiveURLPropName(dsName, true)); } } }); } + + private static String datasourceReactiveURLPropName(String dsName, boolean quotedName) { + StringBuilder key = new StringBuilder("quarkus.datasource"); + key.append('.'); + if (quotedName) { + key.append('"'); + } + key.append(dsName); + if (quotedName) { + key.append('"'); + } + key.append(".reactive.url"); + return key.toString(); + } } diff --git a/extensions/reactive-mssql-client/deployment/pom.xml b/extensions/reactive-mssql-client/deployment/pom.xml index 986ccd6f20919..1e9e6a924112c 100644 --- a/extensions/reactive-mssql-client/deployment/pom.xml +++ b/extensions/reactive-mssql-client/deployment/pom.xml @@ -64,6 +64,11 @@ quarkus-smallrye-health-deployment test + + org.assertj + assertj-core + test + diff --git a/extensions/reactive-mssql-client/deployment/src/main/java/io/quarkus/reactive/mssql/client/deployment/ReactiveMSSQLClientProcessor.java b/extensions/reactive-mssql-client/deployment/src/main/java/io/quarkus/reactive/mssql/client/deployment/ReactiveMSSQLClientProcessor.java index 02a98ae5f3e0d..f7e517d21257a 100644 --- a/extensions/reactive-mssql-client/deployment/src/main/java/io/quarkus/reactive/mssql/client/deployment/ReactiveMSSQLClientProcessor.java +++ b/extensions/reactive-mssql-client/deployment/src/main/java/io/quarkus/reactive/mssql/client/deployment/ReactiveMSSQLClientProcessor.java @@ -2,6 +2,7 @@ import java.util.List; import java.util.Optional; +import java.util.function.Function; import javax.enterprise.context.ApplicationScoped; @@ -83,7 +84,16 @@ ServiceStartBuildItem build(BuildProducer feature, @BuildStep DevServicesDatasourceConfigurationHandlerBuildItem devDbHandler() { - return DevServicesDatasourceConfigurationHandlerBuildItem.reactive(DatabaseKind.MSSQL); + return DevServicesDatasourceConfigurationHandlerBuildItem.reactive(DatabaseKind.MSSQL, new Function() { + @Override + public String apply(String url) { + url = url.replaceFirst("jdbc:", "vertx-reactive:"); + if (url.endsWith(";encrypt=false")) { + return url.substring(0, url.length() - ";encrypt=false".length()); + } + return url; + } + }); } @BuildStep diff --git a/extensions/reactive-mssql-client/deployment/src/test/java/io/quarkus/reactive/mssql/client/DevServicesMsSQLDatasourceTestCase.java b/extensions/reactive-mssql-client/deployment/src/test/java/io/quarkus/reactive/mssql/client/DevServicesMsSQLDatasourceTestCase.java new file mode 100644 index 0000000000000..13d9012c7e235 --- /dev/null +++ b/extensions/reactive-mssql-client/deployment/src/test/java/io/quarkus/reactive/mssql/client/DevServicesMsSQLDatasourceTestCase.java @@ -0,0 +1,40 @@ +package io.quarkus.reactive.mssql.client; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.time.Duration; +import java.util.Locale; +import java.util.logging.Level; +import java.util.logging.LogRecord; + +import javax.inject.Inject; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusUnitTest; +import io.vertx.mutiny.mssqlclient.MSSQLPool; + +public class DevServicesMsSQLDatasourceTestCase { + + @RegisterExtension + static QuarkusUnitTest test = new QuarkusUnitTest() + .withApplicationRoot((jar) -> jar + .addAsResource("container-license-acceptance.txt")) + // Expect no warnings from reactive + .setLogRecordPredicate(record -> record.getLevel().intValue() >= Level.WARNING.intValue() + && record.getMessage().toLowerCase(Locale.ENGLISH).contains("reactive")) + .assertLogRecords(records -> assertThat(records) + // This is just to get meaningful error messages, as LogRecord doesn't have a toString() + .extracting(LogRecord::getMessage) + .isEmpty()); + + @Inject + MSSQLPool pool; + + @Test + public void testDatasource() throws Exception { + pool.withConnection(conn -> conn.query("SELECT 1").execute().replaceWithVoid()) + .await().atMost(Duration.ofMinutes(2)); + } +} From a2b171282a47710889301346501a6506f0d97612 Mon Sep 17 00:00:00 2001 From: Thomas Segismont Date: Tue, 10 May 2022 18:47:03 +0200 Subject: [PATCH 2/3] DevServices DS test cases for reactive Oracle, Pg and MySQL clients --- .../reactive-mysql-client/deployment/pom.xml | 5 +++ .../DevServicesMySQLDatasourceTestCase.java | 39 +++++++++++++++++++ .../reactive-oracle-client/deployment/pom.xml | 5 +++ .../DevServicesOracleDatasourceTestCase.java | 39 +++++++++++++++++++ .../reactive-pg-client/deployment/pom.xml | 5 +++ ...vServicesPostgresqlDatasourceTestCase.java | 39 +++++++++++++++++++ 6 files changed, 132 insertions(+) create mode 100644 extensions/reactive-mysql-client/deployment/src/test/java/io/quarkus/reactive/mysql/client/DevServicesMySQLDatasourceTestCase.java create mode 100644 extensions/reactive-oracle-client/deployment/src/test/java/io/quarkus/reactive/oracle/client/DevServicesOracleDatasourceTestCase.java create mode 100644 extensions/reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/DevServicesPostgresqlDatasourceTestCase.java diff --git a/extensions/reactive-mysql-client/deployment/pom.xml b/extensions/reactive-mysql-client/deployment/pom.xml index caef8a588fe1e..7b8ace10d1df6 100644 --- a/extensions/reactive-mysql-client/deployment/pom.xml +++ b/extensions/reactive-mysql-client/deployment/pom.xml @@ -80,6 +80,11 @@ quarkus-smallrye-health-deployment test + + org.assertj + assertj-core + test + diff --git a/extensions/reactive-mysql-client/deployment/src/test/java/io/quarkus/reactive/mysql/client/DevServicesMySQLDatasourceTestCase.java b/extensions/reactive-mysql-client/deployment/src/test/java/io/quarkus/reactive/mysql/client/DevServicesMySQLDatasourceTestCase.java new file mode 100644 index 0000000000000..7d55f33663932 --- /dev/null +++ b/extensions/reactive-mysql-client/deployment/src/test/java/io/quarkus/reactive/mysql/client/DevServicesMySQLDatasourceTestCase.java @@ -0,0 +1,39 @@ +package io.quarkus.reactive.mysql.client; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.time.Duration; +import java.util.Locale; +import java.util.logging.Level; +import java.util.logging.LogRecord; + +import javax.inject.Inject; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusUnitTest; +import io.vertx.mutiny.mysqlclient.MySQLPool; + +public class DevServicesMySQLDatasourceTestCase { + + @RegisterExtension + static QuarkusUnitTest test = new QuarkusUnitTest() + .withEmptyApplication() + // Expect no warnings from reactive + .setLogRecordPredicate(record -> record.getLevel().intValue() >= Level.WARNING.intValue() + && record.getMessage().toLowerCase(Locale.ENGLISH).contains("reactive")) + .assertLogRecords(records -> assertThat(records) + // This is just to get meaningful error messages, as LogRecord doesn't have a toString() + .extracting(LogRecord::getMessage) + .isEmpty()); + + @Inject + MySQLPool pool; + + @Test + public void testDatasource() throws Exception { + pool.withConnection(conn -> conn.query("SELECT 1").execute().replaceWithVoid()) + .await().atMost(Duration.ofMinutes(2)); + } +} diff --git a/extensions/reactive-oracle-client/deployment/pom.xml b/extensions/reactive-oracle-client/deployment/pom.xml index 6a29f275650e5..4dca4904e4256 100644 --- a/extensions/reactive-oracle-client/deployment/pom.xml +++ b/extensions/reactive-oracle-client/deployment/pom.xml @@ -64,6 +64,11 @@ quarkus-smallrye-health-deployment test + + org.assertj + assertj-core + test + diff --git a/extensions/reactive-oracle-client/deployment/src/test/java/io/quarkus/reactive/oracle/client/DevServicesOracleDatasourceTestCase.java b/extensions/reactive-oracle-client/deployment/src/test/java/io/quarkus/reactive/oracle/client/DevServicesOracleDatasourceTestCase.java new file mode 100644 index 0000000000000..10ccb9b422676 --- /dev/null +++ b/extensions/reactive-oracle-client/deployment/src/test/java/io/quarkus/reactive/oracle/client/DevServicesOracleDatasourceTestCase.java @@ -0,0 +1,39 @@ +package io.quarkus.reactive.oracle.client; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.time.Duration; +import java.util.Locale; +import java.util.logging.Level; +import java.util.logging.LogRecord; + +import javax.inject.Inject; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusUnitTest; +import io.vertx.mutiny.oracleclient.OraclePool; + +public class DevServicesOracleDatasourceTestCase { + + @RegisterExtension + static QuarkusUnitTest test = new QuarkusUnitTest() + .withEmptyApplication() + // Expect no warnings from reactive + .setLogRecordPredicate(record -> record.getLevel().intValue() >= Level.WARNING.intValue() + && record.getMessage().toLowerCase(Locale.ENGLISH).contains("reactive")) + .assertLogRecords(records -> assertThat(records) + // This is just to get meaningful error messages, as LogRecord doesn't have a toString() + .extracting(LogRecord::getMessage) + .isEmpty()); + + @Inject + OraclePool pool; + + @Test + public void testDatasource() throws Exception { + pool.withConnection(conn -> conn.query("SELECT 1 FROM DUAL").execute().replaceWithVoid()) + .await().atMost(Duration.ofMinutes(2)); + } +} diff --git a/extensions/reactive-pg-client/deployment/pom.xml b/extensions/reactive-pg-client/deployment/pom.xml index bbc50cedf6d63..dfcda17b2a048 100644 --- a/extensions/reactive-pg-client/deployment/pom.xml +++ b/extensions/reactive-pg-client/deployment/pom.xml @@ -64,6 +64,11 @@ quarkus-smallrye-health-deployment test + + org.assertj + assertj-core + test + diff --git a/extensions/reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/DevServicesPostgresqlDatasourceTestCase.java b/extensions/reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/DevServicesPostgresqlDatasourceTestCase.java new file mode 100644 index 0000000000000..7866181f5fba7 --- /dev/null +++ b/extensions/reactive-pg-client/deployment/src/test/java/io/quarkus/reactive/pg/client/DevServicesPostgresqlDatasourceTestCase.java @@ -0,0 +1,39 @@ +package io.quarkus.reactive.pg.client; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.time.Duration; +import java.util.Locale; +import java.util.logging.Level; +import java.util.logging.LogRecord; + +import javax.inject.Inject; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusUnitTest; +import io.vertx.mutiny.pgclient.PgPool; + +public class DevServicesPostgresqlDatasourceTestCase { + + @RegisterExtension + static QuarkusUnitTest test = new QuarkusUnitTest() + .withEmptyApplication() + // Expect no warnings from reactive + .setLogRecordPredicate(record -> record.getLevel().intValue() >= Level.WARNING.intValue() + && record.getMessage().toLowerCase(Locale.ENGLISH).contains("reactive")) + .assertLogRecords(records -> assertThat(records) + // This is just to get meaningful error messages, as LogRecord doesn't have a toString() + .extracting(LogRecord::getMessage) + .isEmpty()); + + @Inject + PgPool pool; + + @Test + public void testDatasource() throws Exception { + pool.withConnection(conn -> conn.query("SELECT 1").execute().replaceWithVoid()) + .await().atMost(Duration.ofMinutes(2)); + } +} From 1254a7ee50c118c784ae8a35684e9eabf7f1fcb1 Mon Sep 17 00:00:00 2001 From: Thomas Segismont Date: Fri, 13 May 2022 19:50:17 +0200 Subject: [PATCH 3/3] Let DevServices processors provide a reactive datasource URL This is simpler than transforming a JDBC url string. --- ...tasourceConfigurationHandlerBuildItem.java | 26 ++++++------------- .../spi/DevServicesDatasourceProvider.java | 17 ++++++++---- .../deployment/DB2DevServicesProcessor.java | 5 ++++ .../deployment/DerbyDevServicesProcessor.java | 1 + .../h2/deployment/H2DevServicesProcessor.java | 1 + .../MariaDBDevServicesProcessor.java | 5 ++++ .../deployment/MSSQLDevServicesProcessor.java | 11 ++++++++ .../deployment/MySQLDevServicesProcessor.java | 5 ++++ .../OracleDevServicesProcessor.java | 5 ++++ .../PostgresqlDevServicesProcessor.java | 5 ++++ .../ReactiveMSSQLClientProcessor.java | 12 +-------- 11 files changed, 59 insertions(+), 34 deletions(-) diff --git a/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceConfigurationHandlerBuildItem.java b/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceConfigurationHandlerBuildItem.java index 65a1a1a02138d..bdbd71fd0c34a 100644 --- a/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceConfigurationHandlerBuildItem.java +++ b/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceConfigurationHandlerBuildItem.java @@ -3,7 +3,6 @@ import java.util.Collections; import java.util.Map; import java.util.function.BiFunction; -import java.util.function.Function; import java.util.function.Predicate; import io.quarkus.builder.item.MultiBuildItem; @@ -56,15 +55,16 @@ public static DevServicesDatasourceConfigurationHandlerBuildItem jdbc(String dbK @Override public Map apply(String dsName, DevServicesDatasourceProvider.RunningDevServicesDatasource runningDevDb) { + String jdbcUrl = runningDevDb.getJdbcUrl(); if (dsName == null) { - return Collections.singletonMap("quarkus.datasource.jdbc.url", runningDevDb.getUrl()); + return Collections.singletonMap("quarkus.datasource.jdbc.url", jdbcUrl); } else { // we use quoted and unquoted versions because depending on whether a user configured other JDBC properties // one of the URLs may be ignored // see https://github.com/quarkusio/quarkus/issues/21387 return Map.of( - datasourceURLPropName(dsName), runningDevDb.getUrl(), - datasourceURLPropName("\"" + dsName + "\""), runningDevDb.getUrl()); + datasourceURLPropName(dsName), jdbcUrl, + datasourceURLPropName("\"" + dsName + "\""), jdbcUrl); } } @@ -86,31 +86,21 @@ private static String datasourceURLPropName(String dsName) { } public static DevServicesDatasourceConfigurationHandlerBuildItem reactive(String dbKind) { - return reactive(dbKind, new Function() { - @Override - public String apply(String url) { - return url.replaceFirst("jdbc:", "vertx-reactive:"); - } - }); - } - - public static DevServicesDatasourceConfigurationHandlerBuildItem reactive(String dbKind, - Function jdbcUrlTransformer) { return new DevServicesDatasourceConfigurationHandlerBuildItem(dbKind, new BiFunction>() { @Override public Map apply(String dsName, DevServicesDatasourceProvider.RunningDevServicesDatasource runningDevDb) { - String url = jdbcUrlTransformer.apply(runningDevDb.getUrl()); + String reactiveUrl = runningDevDb.getReactiveUrl(); if (dsName == null) { - return Collections.singletonMap("quarkus.datasource.reactive.url", url); + return Collections.singletonMap("quarkus.datasource.reactive.url", reactiveUrl); } else { // we use quoted and unquoted versions because depending on whether a user configured other JDBC properties // one of the URLs may be ignored // see https://github.com/quarkusio/quarkus/issues/21387 return Map.of( - datasourceReactiveURLPropName(dsName, false), url, - datasourceReactiveURLPropName(dsName, true), url); + datasourceReactiveURLPropName(dsName, false), reactiveUrl, + datasourceReactiveURLPropName(dsName, true), reactiveUrl); } } }, new Predicate() { diff --git a/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceProvider.java b/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceProvider.java index 25bd51c5571ed..d83a95aad15c9 100644 --- a/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceProvider.java +++ b/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceProvider.java @@ -24,14 +24,17 @@ default boolean isDockerRequired() { class RunningDevServicesDatasource { private final String id; - private final String url; + private final String jdbcUrl; + private final String reactiveUrl; private final String username; private final String password; private final Closeable closeTask; - public RunningDevServicesDatasource(String id, String url, String username, String password, Closeable closeTask) { + public RunningDevServicesDatasource(String id, String jdbcUrl, String reactiveUrl, String username, String password, + Closeable closeTask) { this.id = id; - this.url = url; + this.jdbcUrl = jdbcUrl; + this.reactiveUrl = reactiveUrl; this.username = username; this.password = password; this.closeTask = closeTask; @@ -41,8 +44,12 @@ public String getId() { return id; } - public String getUrl() { - return url; + public String getJdbcUrl() { + return jdbcUrl; + } + + public String getReactiveUrl() { + return reactiveUrl; } public Closeable getCloseTask() { diff --git a/extensions/devservices/db2/src/main/java/io/quarkus/devservices/db2/deployment/DB2DevServicesProcessor.java b/extensions/devservices/db2/src/main/java/io/quarkus/devservices/db2/deployment/DB2DevServicesProcessor.java index 6cb6b90aa0704..bf543b291e082 100644 --- a/extensions/devservices/db2/src/main/java/io/quarkus/devservices/db2/deployment/DB2DevServicesProcessor.java +++ b/extensions/devservices/db2/src/main/java/io/quarkus/devservices/db2/deployment/DB2DevServicesProcessor.java @@ -46,6 +46,7 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt return new RunningDevServicesDatasource(container.getContainerId(), container.getEffectiveJdbcUrl(), + container.getReactiveUrl(), container.getUsername(), container.getPassword(), new ContainerShutdownCloseable(container, "IBM Db2")); @@ -97,5 +98,9 @@ public String getEffectiveJdbcUrl() { return super.getJdbcUrl(); } } + + public String getReactiveUrl() { + return getEffectiveJdbcUrl().replaceFirst("jdbc:", "vertx-reactive:"); + } } } diff --git a/extensions/devservices/derby/src/main/java/io/quarkus/devservices/derby/deployment/DerbyDevServicesProcessor.java b/extensions/devservices/derby/src/main/java/io/quarkus/devservices/derby/deployment/DerbyDevServicesProcessor.java index 4a2389fe066cf..d76492fc2fddb 100644 --- a/extensions/devservices/derby/src/main/java/io/quarkus/devservices/derby/deployment/DerbyDevServicesProcessor.java +++ b/extensions/devservices/derby/src/main/java/io/quarkus/devservices/derby/deployment/DerbyDevServicesProcessor.java @@ -69,6 +69,7 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt + additionalArgs.toString(), null, null, + null, new Closeable() { @Override public void close() throws IOException { diff --git a/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java b/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java index 9b4fb7a7200aa..3505b54791208 100644 --- a/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java +++ b/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java @@ -53,6 +53,7 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt + ";DB_CLOSE_DELAY=-1" + additionalArgs.toString(); return new RunningDevServicesDatasource(null, connectionUrl, + null, "sa", "sa", new Closeable() { diff --git a/extensions/devservices/mariadb/src/main/java/io/quarkus/devservices/mariadb/deployment/MariaDBDevServicesProcessor.java b/extensions/devservices/mariadb/src/main/java/io/quarkus/devservices/mariadb/deployment/MariaDBDevServicesProcessor.java index 4a6d44eed1987..f573785863870 100644 --- a/extensions/devservices/mariadb/src/main/java/io/quarkus/devservices/mariadb/deployment/MariaDBDevServicesProcessor.java +++ b/extensions/devservices/mariadb/src/main/java/io/quarkus/devservices/mariadb/deployment/MariaDBDevServicesProcessor.java @@ -54,6 +54,7 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt return new RunningDevServicesDatasource(container.getContainerId(), container.getEffectiveJdbcUrl(), + container.getReactiveUrl(), container.getUsername(), container.getPassword(), new ContainerShutdownCloseable(container, "MariaDB")); @@ -101,5 +102,9 @@ public String getEffectiveJdbcUrl() { return super.getJdbcUrl(); } } + + public String getReactiveUrl() { + return getEffectiveJdbcUrl().replaceFirst("jdbc:", "vertx-reactive:"); + } } } diff --git a/extensions/devservices/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java b/extensions/devservices/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java index b55693b5f618d..9e01121e019f5 100644 --- a/extensions/devservices/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java +++ b/extensions/devservices/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java @@ -44,6 +44,7 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt return new RunningDevServicesDatasource(container.getContainerId(), container.getEffectiveJdbcUrl(), + container.getReactiveUrl(), container.getUsername(), container.getPassword(), new ContainerShutdownCloseable(container, "Microsoft SQL Server")); @@ -94,5 +95,15 @@ public String getEffectiveJdbcUrl() { return super.getJdbcUrl(); } } + + public String getReactiveUrl() { + StringBuilder url = new StringBuilder("vertx-reactive:sqlserver://"); + if (useSharedNetwork) { + url.append(hostName).append(":").append(MS_SQL_SERVER_PORT); + } else { + url.append(this.getHost()).append(":").append(this.getMappedPort(MS_SQL_SERVER_PORT)); + } + return url.toString(); + } } } diff --git a/extensions/devservices/mysql/src/main/java/io/quarkus/devservices/mysql/deployment/MySQLDevServicesProcessor.java b/extensions/devservices/mysql/src/main/java/io/quarkus/devservices/mysql/deployment/MySQLDevServicesProcessor.java index 23f29ccef7cc7..3ed40df522e66 100644 --- a/extensions/devservices/mysql/src/main/java/io/quarkus/devservices/mysql/deployment/MySQLDevServicesProcessor.java +++ b/extensions/devservices/mysql/src/main/java/io/quarkus/devservices/mysql/deployment/MySQLDevServicesProcessor.java @@ -54,6 +54,7 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt return new RunningDevServicesDatasource(container.getContainerId(), container.getEffectiveJdbcUrl(), + container.getReactiveUrl(), container.getUsername(), container.getPassword(), new ContainerShutdownCloseable(container, "MySQL")); @@ -104,5 +105,9 @@ public String getEffectiveJdbcUrl() { return super.getJdbcUrl(); } } + + public String getReactiveUrl() { + return getEffectiveJdbcUrl().replaceFirst("jdbc:", "vertx-reactive:"); + } } } diff --git a/extensions/devservices/oracle/src/main/java/io/quarkus/devservices/oracle/deployment/OracleDevServicesProcessor.java b/extensions/devservices/oracle/src/main/java/io/quarkus/devservices/oracle/deployment/OracleDevServicesProcessor.java index bb9ca8ae8571d..ef5ddd6984e4b 100644 --- a/extensions/devservices/oracle/src/main/java/io/quarkus/devservices/oracle/deployment/OracleDevServicesProcessor.java +++ b/extensions/devservices/oracle/src/main/java/io/quarkus/devservices/oracle/deployment/OracleDevServicesProcessor.java @@ -60,6 +60,7 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt return new RunningDevServicesDatasource(container.getContainerId(), container.getEffectiveJdbcUrl(), + container.getReactiveUrl(), container.getUsername(), container.getPassword(), new ContainerShutdownCloseable(container, "Oracle")); @@ -110,5 +111,9 @@ public String getEffectiveJdbcUrl() { return super.getJdbcUrl(); } } + + public String getReactiveUrl() { + return getEffectiveJdbcUrl().replaceFirst("jdbc:", "vertx-reactive:"); + } } } diff --git a/extensions/devservices/postgresql/src/main/java/io/quarkus/devservices/postgresql/deployment/PostgresqlDevServicesProcessor.java b/extensions/devservices/postgresql/src/main/java/io/quarkus/devservices/postgresql/deployment/PostgresqlDevServicesProcessor.java index 7eee0c6b74ef0..74ac846069e6b 100644 --- a/extensions/devservices/postgresql/src/main/java/io/quarkus/devservices/postgresql/deployment/PostgresqlDevServicesProcessor.java +++ b/extensions/devservices/postgresql/src/main/java/io/quarkus/devservices/postgresql/deployment/PostgresqlDevServicesProcessor.java @@ -54,6 +54,7 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt return new RunningDevServicesDatasource(container.getContainerId(), container.getEffectiveJdbcUrl(), + container.getReactiveUrl(), container.getUsername(), container.getPassword(), new ContainerShutdownCloseable(container, "PostgreSQL")); @@ -107,5 +108,9 @@ public String getEffectiveJdbcUrl() { return super.getJdbcUrl(); } } + + public String getReactiveUrl() { + return getEffectiveJdbcUrl().replaceFirst("jdbc:", "vertx-reactive:"); + } } } diff --git a/extensions/reactive-mssql-client/deployment/src/main/java/io/quarkus/reactive/mssql/client/deployment/ReactiveMSSQLClientProcessor.java b/extensions/reactive-mssql-client/deployment/src/main/java/io/quarkus/reactive/mssql/client/deployment/ReactiveMSSQLClientProcessor.java index f7e517d21257a..02a98ae5f3e0d 100644 --- a/extensions/reactive-mssql-client/deployment/src/main/java/io/quarkus/reactive/mssql/client/deployment/ReactiveMSSQLClientProcessor.java +++ b/extensions/reactive-mssql-client/deployment/src/main/java/io/quarkus/reactive/mssql/client/deployment/ReactiveMSSQLClientProcessor.java @@ -2,7 +2,6 @@ import java.util.List; import java.util.Optional; -import java.util.function.Function; import javax.enterprise.context.ApplicationScoped; @@ -84,16 +83,7 @@ ServiceStartBuildItem build(BuildProducer feature, @BuildStep DevServicesDatasourceConfigurationHandlerBuildItem devDbHandler() { - return DevServicesDatasourceConfigurationHandlerBuildItem.reactive(DatabaseKind.MSSQL, new Function() { - @Override - public String apply(String url) { - url = url.replaceFirst("jdbc:", "vertx-reactive:"); - if (url.endsWith(";encrypt=false")) { - return url.substring(0, url.length() - ";encrypt=false".length()); - } - return url; - } - }); + return DevServicesDatasourceConfigurationHandlerBuildItem.reactive(DatabaseKind.MSSQL); } @BuildStep