Skip to content

Wrong jOOQ exception translator with empty db name #44869

Closed as not planned
Closed as not planned
@MelleD

Description

@MelleD

If there is no db product name in jOOQ available the sql error state translator is used by default:

See:
https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/DefaultExceptionTranslatorExecuteListener.java#L116

	return (dbName != null) ? new SQLErrorCodeSQLExceptionTranslator(dbName)
					: new SQLStateSQLExceptionTranslator();

During discussion of this ticket, we figured out the translator chain is not correct.
Matching the core Spring fallback chain, it should using the SQLErrorCodeSQLExceptionTranslator for empty dbName.

Also the javadoc from SQLErrorCodeSQLExceptionTranslator gives a hint not to use this a main translator:
SQLErrorCodeSQLExceptionTranslator
"This translator is commonly used as a fallback behind a primary translator such as SQLErrorCodeSQLExceptionTranslator or SQLExceptionSubclassTranslator.
"

So IMHO this line should changed to:

		return (dbName != null) ? new SQLErrorCodeSQLExceptionTranslator(dbName)
					: new SQLErrorCodeSQLExceptionTranslator();

Metadata

Metadata

Assignees

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