Skip to content

SQLCODE=-302 truncateExitDescription in JdbcStepExecutionDao.java  #4311

@UliTheGrey

Description

@UliTheGrey

Bug description
When UTF-8 Characters (e.g. from localized error messages) are present, the truncateExitDescription will truncate to 2500 characters, but actual String is > 2500 bytes which makes job-databases (e.g. DB2 LUW) relying on actual length in bytes throw an error.

Environment
Spring Batch version 5,
Java version 17
database DB2 LUW

Steps to reproduce
Try to make a duplicate entry into Db2 LUW configured for german language with german error messages. The exit message will begin with

"org.springframework.dao.DuplicateKeyException: PreparedStatementCallback; SQL [INSERT INTO ...) VALUES (?, ?, ?, ?, ?, ?)]; [jcc][t4][102][10040][4.25.13] Batchfehler. Der Batch wurde übergeben, jedoch ist mindestens eine Ausnahmebedingung bei einem Einzelelement im Batch aufgetreten."

Spring now tries to insert this exit message into the job-database (also DB2 LUW). It does call truncateExitDescription(String description) as the DDL limits this column to 2500.

After that truncate:
exitDescription.value.length is 2500
yet
exitDescription.getBytes().length is 2502

Expected behavior
exitDescription.getBytes().length should be 2500

Minimal Complete Reproducible example
As long as there is a job-database that is byte-length and a stack-trace long enough any exception with a suitable character in it should produce the error when writing the exit-message.
Try

 throw new RuntimeException("§") ;

anywhere in the batch for example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: duplicateIssues that are duplicates of other issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions