@@ -80,7 +80,6 @@ private ConnectionFactoryUtils() {}
80
80
* Translates exceptions into the Spring hierarchy of unchecked generic
81
81
* data access exceptions, simplifying calling code and making any
82
82
* exception that is thrown more meaningful.
83
- *
84
83
* <p>Is aware of a corresponding Connection bound to the current
85
84
* {@link TransactionSynchronizationManager}. Will bind a Connection to the
86
85
* {@link TransactionSynchronizationManager} if transaction synchronization is active.
@@ -99,7 +98,6 @@ public static Mono<Connection> getConnection(ConnectionFactory connectionFactory
99
98
/**
100
99
* Actually obtain a R2DBC Connection from the given {@link ConnectionFactory}.
101
100
* Same as {@link #getConnection}, but preserving the original exceptions.
102
- *
103
101
* <p>Is aware of a corresponding Connection bound to the current
104
102
* {@link TransactionSynchronizationManager}. Will bind a Connection to the
105
103
* {@link TransactionSynchronizationManager} if transaction synchronization is active
@@ -193,11 +191,9 @@ public static Mono<Void> releaseConnection(Connection con, ConnectionFactory con
193
191
* @param connectionFactory the {@link ConnectionFactory} that the Connection was obtained from
194
192
* @see #doGetConnection
195
193
*/
196
- public static Mono <Void > doReleaseConnection (Connection connection ,
197
- ConnectionFactory connectionFactory ) {
194
+ public static Mono <Void > doReleaseConnection (Connection connection , ConnectionFactory connectionFactory ) {
198
195
return TransactionSynchronizationManager .forCurrentTransaction ()
199
196
.flatMap (synchronizationManager -> {
200
-
201
197
ConnectionHolder conHolder = (ConnectionHolder ) synchronizationManager .getResource (connectionFactory );
202
198
if (conHolder != null && connectionEquals (conHolder , connection )) {
203
199
// It's the transactional Connection: Don't close it.
@@ -235,7 +231,6 @@ public static Mono<ConnectionFactory> currentConnectionFactory(ConnectionFactory
235
231
* @return the corresponding DataAccessException instance
236
232
*/
237
233
public static DataAccessException convertR2dbcException (String task , @ Nullable String sql , R2dbcException ex ) {
238
-
239
234
if (ex instanceof R2dbcTransientException ) {
240
235
if (ex instanceof R2dbcTransientResourceException ) {
241
236
return new TransientDataAccessResourceException (buildMessage (task , sql , ex ), ex );
@@ -247,7 +242,6 @@ public static DataAccessException convertR2dbcException(String task, @Nullable S
247
242
return new QueryTimeoutException (buildMessage (task , sql , ex ), ex );
248
243
}
249
244
}
250
-
251
245
if (ex instanceof R2dbcNonTransientException ) {
252
246
if (ex instanceof R2dbcNonTransientResourceException ) {
253
247
return new DataAccessResourceFailureException (buildMessage (task , sql , ex ), ex );
@@ -262,7 +256,6 @@ public static DataAccessException convertR2dbcException(String task, @Nullable S
262
256
return new BadSqlGrammarException (task , (sql != null ? sql : "" ), ex );
263
257
}
264
258
}
265
-
266
259
return new UncategorizedR2dbcException (buildMessage (task , sql , ex ), sql , ex );
267
260
}
268
261
@@ -326,7 +319,6 @@ public static Connection getTargetConnection(Connection con) {
326
319
* @see #CONNECTION_SYNCHRONIZATION_ORDER
327
320
*/
328
321
private static int getConnectionSynchronizationOrder (ConnectionFactory connectionFactory ) {
329
-
330
322
int order = CONNECTION_SYNCHRONIZATION_ORDER ;
331
323
ConnectionFactory current = connectionFactory ;
332
324
while (current instanceof DelegatingConnectionFactory ) {
@@ -336,6 +328,7 @@ private static int getConnectionSynchronizationOrder(ConnectionFactory connectio
336
328
return order ;
337
329
}
338
330
331
+
339
332
/**
340
333
* Callback for resource cleanup at the end of a non-native R2DBC transaction.
341
334
*/
@@ -355,7 +348,6 @@ private static class ConnectionSynchronization implements TransactionSynchroniza
355
348
this .order = getConnectionSynchronizationOrder (connectionFactory );
356
349
}
357
350
358
-
359
351
@ Override
360
352
public int getOrder () {
361
353
return this .order ;
@@ -387,7 +379,8 @@ public Mono<Void> suspend() {
387
379
public Mono <Void > resume () {
388
380
if (this .holderActive ) {
389
381
return TransactionSynchronizationManager .forCurrentTransaction ()
390
- .doOnNext (synchronizationManager -> synchronizationManager .bindResource (this .connectionFactory , this .connectionHolder ))
382
+ .doOnNext (synchronizationManager ->
383
+ synchronizationManager .bindResource (this .connectionFactory , this .connectionHolder ))
391
384
.then ();
392
385
}
393
386
return Mono .empty ();
@@ -401,8 +394,7 @@ public Mono<Void> beforeCompletion() {
401
394
// to avoid issues with strict transaction implementations that expect
402
395
// the close call before transaction completion.
403
396
if (!this .connectionHolder .isOpen ()) {
404
- return TransactionSynchronizationManager .forCurrentTransaction ()
405
- .flatMap (synchronizationManager -> {
397
+ return TransactionSynchronizationManager .forCurrentTransaction ().flatMap (synchronizationManager -> {
406
398
synchronizationManager .unbindResource (this .connectionFactory );
407
399
this .holderActive = false ;
408
400
if (this .connectionHolder .hasConnection ()) {
@@ -439,4 +431,5 @@ public Mono<Void> afterCompletion(int status) {
439
431
return Mono .empty ();
440
432
}
441
433
}
434
+
442
435
}
0 commit comments