United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6503356 CachedRowSetImpl getCurrentRow does not check for cursorPos=0 causing ArrayIndexOutOfBoundsException
JDK-6503356 : CachedRowSetImpl getCurrentRow does not check for cursorPos=0 causing ArrayIndexOutOfBoundsException

Details
Type:
Bug
Submit Date:
2006-12-12
Status:
Closed
Updated Date:
2010-04-03
Project Name:
JDK
Resolved Date:
2008-03-27
Component:
core-libs
OS:
generic
Sub-Component:
javax.sql
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:
6u4 (b01)

Related Reports
Backport:

Sub Tasks

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
                                     
2007-07-11



Hardware and Software, Engineered to Work Together