Skip to content

Commit 769a6d2

Browse files
committed
Update to vertx-core changes.
1 parent 491505e commit 769a6d2

File tree

6 files changed

+25
-11
lines changed

6 files changed

+25
-11
lines changed

vertx-db2-client/src/main/java/io/vertx/db2client/spi/DB2Driver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public Pool newPool(Vertx vertx, Supplier<Future<DB2ConnectOptions>> databases,
5050
VertxInternal vx = (VertxInternal) vertx;
5151
PoolImpl pool;
5252
if (options.isShared()) {
53-
pool = vx.createSharedClient(SHARED_CLIENT_KEY, options.getName(), closeFuture, cf -> newPoolImpl(vx, databases, options, cf));
53+
pool = vx.createSharedResource(SHARED_CLIENT_KEY, options.getName(), closeFuture, cf -> newPoolImpl(vx, databases, options, cf));
5454
} else {
5555
pool = newPoolImpl(vx, databases, options, closeFuture);
5656
}

vertx-mssql-client/src/main/java/io/vertx/mssqlclient/spi/MSSQLDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public Pool newPool(Vertx vertx, Supplier<Future<MSSQLConnectOptions>> databases
5353
VertxInternal vx = (VertxInternal) vertx;
5454
PoolImpl pool;
5555
if (options.isShared()) {
56-
pool = vx.createSharedClient(SHARED_CLIENT_KEY, options.getName(), closeFuture, cf -> newPoolImpl(vx, databases, options, cf));
56+
pool = vx.createSharedResource(SHARED_CLIENT_KEY, options.getName(), closeFuture, cf -> newPoolImpl(vx, databases, options, cf));
5757
} else {
5858
pool = newPoolImpl(vx, databases, options, closeFuture);
5959
}

vertx-mysql-client/src/main/java/io/vertx/mysqlclient/spi/MySQLDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public Pool newPool(Vertx vertx, Supplier<Future<MySQLConnectOptions>> databases
5050
VertxInternal vx = (VertxInternal) vertx;
5151
PoolImpl pool;
5252
if (options.isShared()) {
53-
pool = vx.createSharedClient(SHARED_CLIENT_KEY, options.getName(), closeFuture, cf -> newPoolImpl(vx, databases, options, cf));
53+
pool = vx.createSharedResource(SHARED_CLIENT_KEY, options.getName(), closeFuture, cf -> newPoolImpl(vx, databases, options, cf));
5454
} else {
5555
pool = newPoolImpl(vx, databases, options, closeFuture);
5656
}

vertx-oracle-client/src/main/java/io/vertx/oracleclient/spi/OracleDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public Pool newPool(Vertx vertx, Supplier<Future<OracleConnectOptions>> database
4646
VertxInternal vx = (VertxInternal) vertx;
4747
PoolImpl pool;
4848
if (options.isShared()) {
49-
pool = vx.createSharedClient(SHARED_CLIENT_KEY, options.getName(), closeFuture, cf -> newPoolImpl(vx, databases, options, cf));
49+
pool = vx.createSharedResource(SHARED_CLIENT_KEY, options.getName(), closeFuture, cf -> newPoolImpl(vx, databases, options, cf));
5050
} else {
5151
pool = newPoolImpl(vx, databases, options, closeFuture);
5252
}

vertx-pg-client/src/main/java/io/vertx/pgclient/spi/PgDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public Pool newPool(Vertx vertx, Supplier<Future<PgConnectOptions>> databases, P
3030
VertxInternal vx = (VertxInternal) vertx;
3131
PoolImpl pool;
3232
if (options.isShared()) {
33-
pool = vx.createSharedClient(SHARED_CLIENT_KEY, options.getName(), closeFuture, cf -> newPoolImpl(vx, databases, options, cf));
33+
pool = vx.createSharedResource(SHARED_CLIENT_KEY, options.getName(), closeFuture, cf -> newPoolImpl(vx, databases, options, cf));
3434
} else {
3535
pool = newPoolImpl(vx, databases, options, closeFuture);
3636
}

vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/ConnectionFactoryBase.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,24 @@
1010
*/
1111
package io.vertx.sqlclient.impl;
1212

13+
import io.vertx.core.CompositeFuture;
1314
import io.vertx.core.Future;
1415
import io.vertx.core.Promise;
15-
import io.vertx.core.impl.CloseFuture;
16-
import io.vertx.core.impl.ContextInternal;
17-
import io.vertx.core.impl.EventLoopContext;
18-
import io.vertx.core.impl.VertxInternal;
16+
import io.vertx.core.impl.*;
1917
import io.vertx.core.impl.future.PromiseInternal;
2018
import io.vertx.core.json.JsonObject;
2119
import io.vertx.core.net.NetClient;
2220
import io.vertx.core.net.NetClientOptions;
2321
import io.vertx.core.net.impl.NetClientBuilder;
22+
import io.vertx.core.net.impl.NetClientInternal;
2423
import io.vertx.sqlclient.SqlConnectOptions;
2524
import io.vertx.sqlclient.spi.ConnectionFactory;
2625

2726
import java.util.HashMap;
27+
import java.util.List;
2828
import java.util.Map;
2929
import java.util.function.Supplier;
30+
import java.util.stream.Collectors;
3031

3132
/**
3233
* An base connection factory for creating database connections
@@ -39,16 +40,29 @@ public abstract class ConnectionFactoryBase<C extends SqlConnectOptions> impleme
3940
private final Map<JsonObject, NetClient> clients;
4041

4142
// close hook
42-
protected final CloseFuture clientCloseFuture = new CloseFuture();
43+
protected final CloseSequence clientCloseFuture = new CloseSequence(this::doClose);
4344

4445
protected ConnectionFactoryBase(VertxInternal vertx) {
4546
this.vertx = vertx;
4647
this.clients = new HashMap<>();
4748
}
4849

50+
private void doClose(Promise<Void> p) {
51+
List<Future> futures = clients.values().stream().map(client -> client.close()).collect(Collectors.toList());
52+
53+
CompositeFuture join = CompositeFuture.join(futures);
54+
55+
join.onComplete(ar -> p.complete());
56+
}
57+
4958
private NetClient createNetClient(NetClientOptions options) {
5059
options.setReconnectAttempts(0); // auto-retry is handled on the protocol level instead of network level
51-
return new NetClientBuilder(vertx, options).closeFuture(clientCloseFuture).build();
60+
61+
NetClientInternal netClient = new NetClientBuilder(vertx, options).build();
62+
63+
64+
// return new NetClientBuilder(vertx, options).closeFuture(clientCloseFuture).build();
65+
return netClient;
5266
}
5367

5468
protected NetClient netClient(NetClientOptions options) {

0 commit comments

Comments
 (0)