Skip to content

NPE in JDBC ItemReaders after changes in spring-jdbc's AbstractFallbackSQLExceptionTranslator #3968

Closed
@unintended

Description

@unintended

The spring-jdbc's SQLExceptionTranslator.translate() method is nullable (and was marked as nullable since 2017 spring-projects/spring-framework@87598f4)

However AbstractFallbackSQLExceptionTranslator that is used as base class for all default spring-batch SQLExceptionTranslators become nullable (dirty move but quite legal) since May 2020 spring-projects/spring-framework@e9cded5#diff-c6aa1c6a4b11e8a722808e945c4c5b6ef471c42871c7ce830554dde81ad7f2c2R66

However, all spring-batch readers rely on the non-nullability of the translators, e.g.:

throw getExceptionTranslator().translate("Executing query", getSql(), se);

The NPE happens if some non-standard sql drivers are used/unexpected SQL code is returned and the default translators are not able to translate such SQLException properly.

Expected behavior
The proper way is to check if the translator returned null and throw something like UncategorizedSQLException in that case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions