@@ -51,7 +51,7 @@ public class PoolImpl extends SqlClientBase implements Pool, Closeable {
5151 private long timerID ;
5252 private volatile Function <Context , Future <SqlConnection >> connectionProvider ;
5353
54- private static final String PROPAGATABLE_CONNECTION = "propagatable_connection" ;
54+ public static final String PROPAGATABLE_CONNECTION = "propagatable_connection" ;
5555
5656 public PoolImpl (VertxInternal vertx ,
5757 Driver driver ,
@@ -155,28 +155,9 @@ public Future<SqlConnection> getConnection() {
155155 });
156156 }
157157
158- public <T > Future <@ Nullable T > withTransaction (TransactionPropagation txPropagation ,
159- Function <SqlConnection , Future <@ Nullable T >> function ) {
160- if (txPropagation == TransactionPropagation .CONTEXT ) {
161- ContextInternal context = (ContextInternal ) Vertx .currentContext ();
162- SqlConnection sqlConnection = context .getLocal (PROPAGATABLE_CONNECTION );
163- if (sqlConnection == null ) {
164- return startPropagatableConnection (function );
165- }
166- return context .succeededFuture (sqlConnection )
167- .flatMap (conn -> function .apply (conn )
168- .onFailure (err -> {
169- if (!(err instanceof TransactionRollbackException )) {
170- conn .transaction ().rollback ();
171- }
172- }));
173- }
174- return withTransaction (function );
175- }
176-
177- private <T > Future <@ Nullable T > startPropagatableConnection (Function <SqlConnection , Future <@ Nullable T >> function ) {
158+ public static <T > Future <@ Nullable T > startPropagatableConnection (Pool pool , Function <SqlConnection , Future <@ Nullable T >> function ) {
178159 ContextInternal context = (ContextInternal ) Vertx .currentContext ();
179- return getConnection ().onComplete (handler -> context .putLocal (PROPAGATABLE_CONNECTION , handler .result ()))
160+ return pool . getConnection ().onComplete (handler -> context .putLocal (PROPAGATABLE_CONNECTION , handler .result ()))
180161 .flatMap (conn -> conn
181162 .begin ()
182163 .flatMap (tx -> function
0 commit comments