Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6193078

CachedRowSetImpl.acceptChanges() fails in NPE after calling deleteRow()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 5.0
    • core-libs
    • b81
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.5.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      When using a CachedRowSetImpl with a page size set (i.e. no full caching). Calling rowSet.deleteRow() and then later on rowSet.acceptChanges() produces a Null Pointer Exception (it works fine with setPageSize(0)).

      Please not that in addition to this NPE, some debug traces coming from Sun's code are printed in the console.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run the attach program. I reproduce with mySQL JDBC driver. However I guess it is not specific to the driver. You can modify the parameters to connect to the database you want to.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No output.
      ACTUAL -
      The value of params1 :3
      The value of params1 :essai3
      The value of params1 :1
      The value of params1 :2004-04-29
      The value of params1 :2004-06-21
      The value of params2 :null
      Exception in thread "main" java.lang.NullPointerException
      at com.sun.rowset.internal.CachedRowSetWriter.deleteOriginalRow(CachedRowSetWriter.java:848)
      at com.sun.rowset.internal.CachedRowSetWriter.writeData(CachedRowSetWriter.java:301)
      at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:835)
      at ilog.views.util.data.RowSetPb3.test(RowSetPb3.java:56)
      at ilog.views.util.data.RowSetPb3.main(RowSetPb3.java:35)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :

      package ilog.views.util.data;

      import java.sql.SQLException;

      import javax.sql.RowSet;
      import javax.sql.RowSetMetaData;
      import javax.sql.rowset.CachedRowSet;
      import javax.sql.rowset.FilteredRowSet;
      import javax.sql.rowset.Predicate;

      import com.sun.rowset.CachedRowSetImpl;
      import com.sun.rowset.FilteredRowSetImpl;

      /**
       * @author jolif
       *
       */
      public class RowSetPb3
      {
        final static String databaseURL = "jdbc:mysql:///test";
        final static String user = "";
        final static String passwd = "";
        final static String driverName = "com.mysql.jdbc.Driver";
        final static String TABLE_NAME = "activities";
           
        public RowSetPb3()
        {
        }

        // CJO 11/04
        public static void main(String[] arg)
          throws Exception
        {
          new RowSetPb3().test();
        }
        
        public void test() throws ClassNotFoundException, InstantiationException,
                                  IllegalAccessException, SQLException, InterruptedException
        {
          Class.forName(driverName);
         

          CachedRowSet rowSet = new CachedRowSetImpl();
          rowSet.setPageSize(5);
          rowSet.setUrl(databaseURL);
          rowSet.setUsername(user);
          rowSet.setPassword(passwd);
          rowSet.setCommand("select * from "+TABLE_NAME);
          rowSet.execute();

          rowSet.nextPage();
          rowSet.next();
          rowSet.next();
          rowSet.deleteRow();
          rowSet.acceptChanges();
        }
      }
      ###@###.### 2004-11-09 23:50:39 GMT

            ahandasunw Amit Handa (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: