Optimize uses of onErrorResume()
This commit replaces uses of onErrorResume() with - onErrorMap() in places where onErrorResume() is just used to map to a different exception. - onErrorComplete() where onErrorResume() just maps to Mono.empty(). - onErrorReturn() where onErrorResum() just maps to Mono.just(). Closes gh-31352
This commit is contained in:
@@ -228,8 +228,8 @@ public class R2dbcTransactionManager extends AbstractReactiveTransactionManager
|
||||
.then(Mono.error(ex));
|
||||
}
|
||||
return Mono.error(ex);
|
||||
})).onErrorResume(ex -> Mono.error(new CannotCreateTransactionException(
|
||||
"Could not open R2DBC Connection for transaction", ex)));
|
||||
})).onErrorMap(ex -> new CannotCreateTransactionException(
|
||||
"Could not open R2DBC Connection for transaction", ex));
|
||||
}).then();
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ abstract class AbstractDatabaseClientIntegrationTests {
|
||||
Mono.from(connectionFactory.create())
|
||||
.flatMapMany(connection -> Flux.from(connection.createStatement("DROP TABLE legoset").execute())
|
||||
.flatMap(Result::getRowsUpdated)
|
||||
.onErrorResume(e -> Mono.empty())
|
||||
.onErrorComplete()
|
||||
.thenMany(connection.createStatement(getCreateTableStatement()).execute())
|
||||
.flatMap(Result::getRowsUpdated).thenMany(connection.close())).as(StepVerifier::create)
|
||||
.verifyComplete();
|
||||
|
||||
@@ -69,7 +69,7 @@ abstract class AbstractTransactionalDatabaseClientIntegrationTests {
|
||||
Mono.from(connectionFactory.create())
|
||||
.flatMapMany(connection -> Flux.from(connection.createStatement("DROP TABLE legoset").execute())
|
||||
.flatMap(Result::getRowsUpdated)
|
||||
.onErrorResume(e -> Mono.empty())
|
||||
.onErrorComplete()
|
||||
.thenMany(connection.createStatement(getCreateTableStatement()).execute())
|
||||
.flatMap(Result::getRowsUpdated).thenMany(connection.close())).as(StepVerifier::create).verifyComplete();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user