I would like to set my own Exception Translator or ExecuteListener to translate exception. Currently the exception is always translated twice. Can't the bean be set conditionally? What is the use case for the Order to have 2 beans?
See JooqAutoConfiguration
@Bean
@Order(0)
public DefaultExecuteListenerProvider jooqExceptionTranslatorExecuteListenerProvider() {
return new DefaultExecuteListenerProvider(new JooqExceptionTranslator());
}
Proposal if only 1 provider is necessary
@Bean
@ConditionalOnMissingBean
public DefaultExecuteListenerProvider jooqExceptionTranslatorExecuteListenerProvider() {
return new DefaultExecuteListenerProvider(new JooqExceptionTranslator());
}
Quick Fix with order
@Bean
@Order(0)
@CondationalOnProperty("spring.xyz.jooq.translator.enabled")
public DefaultExecuteListenerProvider jooqExceptionTranslatorExecuteListenerProvider() {
return new DefaultExecuteListenerProvider(new JooqExceptionTranslator());
}
Or own interface for jOOQ Bean Translator
public interface JooqExceptionTranslator extends ExecuteListener
@Bean
@Order(0)
public DefaultExecuteListenerProvider jooqExceptionTranslatorExecuteListenerProvider(JooqExceptionTranslator translator) {
return new DefaultExecuteListenerProvider(translator);
}
@Bean
@ConditionalOnMissingBean
public JooqExceptionTranslator jooqExceptionTranslator() {
return new DefaultJooqExceptionTranslator();
}
What do you think?
Comment From: philwebb
All ExecuteListenerProvider beans currently get passed to org.jooq.impl.DefaultConfiguration.set(...) so I don't think we can make DefaultExecuteListenerProvider conditional. That would help in your case, but not for folks that want a ExecuteListenerProvider bean as well as our JooqExceptionTranslator.
We'd probably also want to avoid @CondationalOnProperty("spring.xyz.jooq.translator.enabled") because as a general rule we try not to add too many *.enabled properties.
I think the third option isn't too bad and perhaps we could even change the existing JooqExceptionTranslator to make it easier to subclass.
I'm curious if you're finding the translation happening twice an actual problem? Is it a performance issue or is it somehow doing a translation that you don't want?
Comment From: MelleD
It's not a real problem. But very confusing when debugging that it is translated 2 times. It is also difficult to understand why the exception is translated twice. It's not intuitive. You also have to pay attention to the order, if it's not correct it won't work. And the third option is not a big change and it's not breaking. So for me would be a good improvement.
Maybe something like this https://github.com/spring-projects/spring-boot/pull/38762
Comment From: mhalbritter
Superseded by #38762.