@@ -51,7 +51,7 @@ public class PoolImpl extends SqlClientBase implements Pool, Closeable {
51
51
private long timerID ;
52
52
private volatile Function <Context , Future <SqlConnection >> connectionProvider ;
53
53
54
- private static final String PROPAGATABLE_CONNECTION = "propagatable_connection" ;
54
+ public static final String PROPAGATABLE_CONNECTION = "propagatable_connection" ;
55
55
56
56
public PoolImpl (VertxInternal vertx ,
57
57
Driver driver ,
@@ -155,28 +155,9 @@ public Future<SqlConnection> getConnection() {
155
155
});
156
156
}
157
157
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 ) {
178
159
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 ()))
180
161
.flatMap (conn -> conn
181
162
.begin ()
182
163
.flatMap (tx -> function
0 commit comments