Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spring-projects-issues opened this issue Nov 4, 2008 · 2 comments
Closed
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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

@spring-projects-issues
Copy link
Collaborator Author

Abhishek Gupta commented

A clarification about the above the description:
The example of "dataIntegrityViolationCodes" given above does not hold true. This does infact get sorted. But there are others which dont for eg:
dataAccessResourceFailureCodes (Although the sql-error-codes.xml file is sorted correctly in this case, users overriding it will still face the problem)
transientDataAccessResourceCodes
invalidResultSetAccessCodes, etc.

Thanks,
Abhi

@spring-projects-issues
Copy link
Collaborator Author

Thomas Risberg commented

Looks like some of the categories are missing the initial sort - this should get fixed.

--Thomas

@spring-projects-issues spring-projects-issues added type: bug A general bug in: data Issues in data modules (jdbc, orm, oxm, tx) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0 M1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant