Skip to content

Make JooqExceptionTranslator conditional  #38736

@MelleD

Description

@MelleD

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by another

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions