-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Add conditional bean for jOOQ exception translator #38762
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 conditional bean for jOOQ exception translator #38762
Conversation
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.
Hello,
thanks for the PR. I've added a comment regarding breaking the public API. Please take a look.
...igure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqExceptionTranslator.java
Outdated
Show resolved
Hide resolved
Yes I can change the name back. Do you have a proposal for the other class names? |
For what class are you looking for a name? I'd leave |
For the new interface? |
Which new interface? I'd leave |
Maybe yes it would work. But looks not really nice to create subclass which using nothing from the parent class just to have the same type to provide a bean. |
There was a proposal in #38736 to "change the existing JooqExceptionTranslator to make it easier to subclass". I think that makes sense and would be less disruptive than the introduction of an interface. |
Yes third option is with interface. And also you can subclass it. That's directly what the proposal was and what I did. |
I don't think we want a new interface. Instead, we'd prefer for Another option would be to make things conditional on a bean with a specific name, somewhat similar (although hopefully a little simpler) to what we do for Spring MVC's |
But why?
|
It's an interface in your current proposal: public interface JooqExceptionTranslator extends ExecuteListener |
Yes I would like to rename the interface + rename the translator class back to JooqExceptionTranslator. |
Although the interface is more flexible, in this instance I think it's best if we make only the smallest change possible required to support the feature. We've learnt from experience that it's harder to remove code than add it, so from our point of view it would be better not to introduce new public API before we need to. |
Yes I know, for our use case we don't need the I honestly don't understand the problem at all. Although it is actually best practice to have an interface and an implementation. What exactly is the problem? |
There's some subtly when it comes to best practices for a general project and best practices for an open source project with many users a long support window. In a general project, the cost of introducing new API isn't that great since the the project is self contained and it's easy to change things without impacting others. For a project such as ours, we need to be more intentional about how and when we introduce new API. We need to consider back compatibility issue and long-term maintenance concerns. For example, we can't accept the pull-request as it stands because it changes If we zoom out a bit, there's a lot of advantages to not adding an interface. We don't break back-compatibility and we don't need to come up with any new class names or introduce new public API. Furthermore, we've not prevented ourselves from adding an interface later if we decide that one is really needed.
This is true, but it's personal opinion that's been formed from a lot of experience managing this project. As a general philosophy, making the smallest change possible required to support a given use-case has historically served us well. |
I understand the reasons also for open source projects (have also some experience), but I don't see it here because the interface provides exactly the same thing as the class. It is just as public as it currently is. There is no new public API, because there is already an interface --> ExecuteListener ;). How I said: |
Introduce an jOOQ `ExecuteListener` sub-interface specifically for exception translation with the auto-configured `DefaultExecuteListenerProvider` instance. Users can now define a bean that implements the interface or omit it and continue to use the existing exception translation logic. See gh-38762
Thanks for the updates to the code @MelleD. Having looked at your changes I've changed my mind about the interface and I agree that it's the better approach. I've merged this into Thanks for the PR! |
Add conditional bean for jOOQ exception translator
#38736