JDK-6503356 : CachedRowSetImpl getCurrentRow does not check for cursorPos=0 causing ArrayIndexOutOfBoundsException
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.sql
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-12-12
  • Updated: 2010-04-03
  • Resolved: 2008-03-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u4 b01Fixed 7Fixed
Description
Source : com/sun/rowset/CachedRowSetImpl.java

  1613      protected BaseRow getCurrentRow() {
  1614          if (onInsertRow == true) {
  1615              return (BaseRow)insertRow;
  1616          } else {
  1617              return (BaseRow)(rvh.get(cursorPos - 1));  <==== SHOULD CHECK FOR 0
  1618          }
  1619      }

Sample Test Code:

    crs = new com.sun.rowset.CachedRowSetImpl();    
    logMsg("\nTest 3:Updating the value of 1st row to 33333333.40");
    crs.first();
    logMsg("Are we at first row ? " + crs.isFirst());
    crs.updateDouble(1, 33333333.40);
    logMsg("Has the column 1 been updated? : " + crs.columnUpdated(1));
    crs.updateRow();
    crs.acceptChanges();
    crs.commit();

Test Execution Output:

[2006-12-11T23:43:59.08] Test java.lang.ArrayIndexOutOfBoundsException: -1
[2006-12-11T23:43:59.31]        at java.util.Vector.get(Vector.java:696)
[2006-12-11T23:43:59.31]        at com.sun.rowset.CachedRowSetImpl.getCurrentRow(Unknown Source)
[2006-12-11T23:43:59.31]        at com.sun.rowset.CachedRowSetImpl.updateDouble(Unknown Source)
[2006-12-11T23:43:59.31]        at DefaultCRSBehavior.doTest(DefaultCRSBehavior.java:146)
[2006-12-11T23:43:59.31]        at DefaultCRSBehavior.main(DefaultCRSBehavior.java:254)
[2006-12-11T23:43:59.31] # Test level exit status: 0
[2006-12-11T23:43:59.31] 3:Updating the value of 1st row to 33333333.40
[2006-12-11T23:43:59.31] Are we at first row ? true
[2006-12-11T23:43:59.31] SOURCE DEBUG: cursorPos - 1 = -1
[2006-12-11T23:43:59.31] DEBUG: Exception caught: -1

Comments
EVALUATION getCurrentRow has to check for cursorPos
11-07-2007