Issue Details (XML | Word | Printable)

Key: SPR-5272
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Thomas Risberg
Reporter: Abhishek Gupta
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Spring Framework

Bug in translating SQLException using Error Codes

Created: 04/Nov/08 06:03 PM   Updated: 20/Nov/08 03:40 PM   Resolved: 20/Nov/08 03:40 PM
Component/s: SpringDA
Affects Version/s: 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5, 2.5.6
Fix Version/s: 3.0 M1

Time Tracking:
Not Specified


 Description  « Hide

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.



Abhishek Gupta added a comment - 04/Nov/08 07:12 PM

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


Thomas Risberg added a comment - 07/Nov/08 12:56 PM

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

--Thomas