-
Notifications
You must be signed in to change notification settings - Fork 353
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
Remove DbActionExecutionException #1956
Conversation
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/AggregateChangeExecutor.java
Outdated
Show resolved
Hide resolved
@@ -110,12 +114,12 @@ private void execute(DbAction<?> action, JdbcAggregateChangeExecutionContext exe | |||
} else { | |||
throw new RuntimeException("unexpected action"); | |||
} | |||
} catch (Exception e) { | |||
} catch (RuntimeException e) { |
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.
It seems to me that we should revisit our exception handling. DbActionExecutionException
doesn't seem particularly useful to the final application whereas it might be useful for our own internals.
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.
@mp911de Yeah... But this is not a part of this issue. Maybe we can create another issue to revise the default exception to be thrown? Or what should we do?
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.
The problem is that we're throwing DbActionExecutionException
and not a DAO exception, so I think that is indeed part of the issue. Looking at the code, we do not catch DbActionExecutionException
. That exception was introduced as part of introducing better means for debugging (#382) while the net effect was that we changed the API experience. What we could do is add DbActionExecutionException
as suppressed exception to the original one.
Paging @schauder.
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.
I'm not sure what you mean by "adding as suppresed exception".
In my understanding Surpressed exceptions are ones that get lost when a finalizer throws an exception itself.
We could instantiate a new exception with the same type as the original with the additional information of the DAEE, or even the DAEE as cause. That would certainly look strange, but might actually be rather useful.
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.
Something along the lines of:
catch(RuntimeException e) {
e.addSuppressed(new DbActionExecutionException(action));
throw e;
}
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.
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.
I didn't know addSuppressed
. It is a little hackish, but seems fine to me. It's not worse then the other variants I had in mind.
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.
Done
ba1f4f0
to
a8fbd8f
Compare
I'm still not happy with this.
I see two possible ways forward: b) Implement a @mp911de What do you think? |
I would honestly drop Going forward, I would even suggest introducing |
Just to clarify what wasn't clear to me from Marks statement: For this PR we want to completely drop the The MyBatis integration should eventually also get its |
What I wrote above, was the result of a discussion with Mark, so please go ahead. |
Understood @schauder. Will complete shortly |
6532a21
to
13673aa
Compare
Because we're removing the Or maybe we can do better - we can just deprecate the |
It's not just about the existence of |
I agree with you @schauder. I'm just pointing out that retaining the Maybe just removing it entirely and not retaining the legacy in the next major version is a good way to go. Thanks! |
I see your idea, but if someone is referencing |
This PR has test failures in |
Signed-off-by: mipo256 <[email protected]>
Fixed the concurrency tests in |
We now raise the exceptions from `NamedParameterJdbcTemplate` directly. If you used to extract the `cause` of a `DbActionExecutionException` you should now catch that Exception directly. Original pull request #1956 Closes #831 Signed-off-by: mipo256 <[email protected]>
We now raise the exceptions from `NamedParameterJdbcTemplate` directly. If you used to extract the `cause` of a `DbActionExecutionException` you should now catch that Exception directly. Original pull request #1956 Closes #831 Signed-off-by: mipo256 <[email protected]>
Thanks for pushing this forward. I applied some polishing and some fixes to SQL scripts and merged it into 4.0.x |
Targeting #831 issue
CC: @schauder @mp911de