-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Add error handling function in R2DBC DatabaseClient
#31942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add error handling function in R2DBC DatabaseClient
#31942
Conversation
|
Thanks for the pull request! From a quick first glance, this looks pretty good to me :-) A code-style note: Please do not use star imports such as A naming note: |
|
oh thanks a lot for detailed review @jhoeller !
✅ I updated PR like above based on your suggestion. thanks! |
sbrannen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename instances of the BiConsumer to errorHandler (or perhaps connectionErrorHandler).
Thanks
spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DatabaseClient.java
Outdated
Show resolved
Hide resolved
spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DefaultDatabaseClient.java
Outdated
Show resolved
Hide resolved
spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DefaultDatabaseClient.java
Outdated
Show resolved
Hide resolved
spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DefaultDatabaseClient.java
Outdated
Show resolved
Hide resolved
spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DefaultDatabaseClient.java
Outdated
Show resolved
Hide resolved
spring-r2dbc/src/test/java/org/springframework/r2dbc/core/DefaultDatabaseClientUnitTests.java
Outdated
Show resolved
Hide resolved
spring-r2dbc/src/test/java/org/springframework/r2dbc/core/DefaultDatabaseClientUnitTests.java
Outdated
Show resolved
Hide resolved
spring-r2dbc/src/test/java/org/springframework/r2dbc/core/DefaultDatabaseClientUnitTests.java
Outdated
Show resolved
Hide resolved
spring-r2dbc/src/test/java/org/springframework/r2dbc/core/DefaultDatabaseClientUnitTests.java
Outdated
Show resolved
Hide resolved
spring-r2dbc/src/test/java/org/springframework/r2dbc/core/DefaultDatabaseClientUnitTests.java
Outdated
Show resolved
Hide resolved
|
@sbrannen @injae-kim indeed, what we register via @mp911de does the overall arrangement look sensible to you? |
|
Taking a step back, I wonder what we actually want to achieve. Generally, connections are released (closed) upon an exception and the error signal is dispatched to the subscriber.
|
I just simply want to make user can handleError with connection like Currently it's impossible cause connection is only used inside of
@mp911de , thanks a lot for your suggestion! |
Hi @@sbrannen, @jhoeller what do you think about above suggestion? If you agree with this, please share to me~! I'll update this PR with this way! I also agree that |
d8c5942 to
6554c16
Compare
|
Rebase to upstream/main to resolve conflict on test~! |
|
Looking at the latest state of this PR, I don't really see how the consumer is related to "connection error". The function that uses the connection may also lead to an error, and if closing the connection fails, it is not invoked. Looking at the javadoc of |
|
spring-framework/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/ConnectionAccessor.java Lines 43 to 47 in fdf187e
/**
* Handle an exception thrown from {@link ConnectionAccessor#inConnection}
* or {@link ConnectionAccessor#inConnectionMany} 👉 (new) during executing a callback {@link Function} within a {@link Connection} scope.
* @param errorHandler a {@code BiConsumer} that handles the connection error
* @since 6.2
*/
Builder onConnectionError(BiConsumer<? super Throwable, ? super Connection> errorHandler)
So it's good to enhance |
I don't think so and I am not sure that is where we want to go anyway. Brainstorming with @mp911de, we'd like to take a step back and resume the conversation on the issue. Specifically by sharing a representative sample of what that would achieve. It's unclear if you're affected by that issue as well or if you're trying to help based on the original report. Either way, let's continue chatting on the issue. Thanks for the PR, in any case! |
aha I got it! let's continue to discuss on issue~ thanks a lot for review 🙇 |
Closes gh-31256
Motivation
DatabaseClient, but currently impossibleModification
Result