Skip to content

Bug in translating SQLException using Error Codes [SPR-5272] #9945

Closed
@spring-projects-issues

Description

@spring-projects-issues

Abhishek Gupta opened SPR-5272 and commented

The SQLErrorCodeSQLExceptionTranslator class does a binary search on the SQLErrorCodes of each category. But binary search expects these to be in ascending order.
Since these error-codes are stored in String[], they need to be in an "alphanumeric" sorted order in the sql-error-codes.xml file.
Following are some examples of this not being the case:

In release 2.5.6 for DB=Sybase the following codes are defined:
<property name="transientDataAccessResourceCodes">
<value>921,1105</value>
</property>

These are in ascending order numerically but since SQLErrorCodeSQLExceptionTranslator does a binary search on String[] this is not ascending alphanumerically

The following break in older version 2.5.5 and older":
<property name="dataIntegrityViolationCodes">
<value>423,511,515,530,547,2601,2615,2714</value>
</property>

There are other such breaks as well in the file.

Instead of fixing the config file to keep the codes sorted alphanumerically, may I suggest that the SQLErrorCodes actually be explicitly sorted on load? In case a user overrides the the sql-error-codes.xml it can easily lead to bugs if the file is not maintained alphanumerically sorted.


Affects: 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5, 2.5.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: dataIssues in data modules (jdbc, orm, oxm, tx)type: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions