Menu

#22 NPE in MockResultSet.isRowEqual()

closed
None
5
2007-08-01
2007-02-13
No

When calling MockResultSet.isRowEqual(int number, List rowData) with a row that contain a null column, a NullPointerException is thrown on the following line:

if(!source.getClass().isAssignableFrom(target.getClass()) && target.getClass().isAssignableFrom(source.getClass()))

The fix appears to be to change the line to:

if(source != null && target != null &&
!source.getClass().isAssignableFrom(target.getClass()) &&
!target.getClass().isAssignableFrom(source.getClass()))

This skips the assigning to string, and ParameterUtils.compareParameter() correctly compares the null values.

This fix works for the code where I found the problem.

Discussion

  • Alwin Ibba

    Alwin Ibba - 2007-02-13

    Logged In: YES
    user_id=804648
    Originator: NO

    Yes this is a bug. Thanks. I'll fix it using your suggestion (which should also applied to isColumnEqual()).

     
  • Alwin Ibba

    Alwin Ibba - 2007-02-13
    • assigned_to: nobody --> aibba
     
  • Alwin Ibba

    Alwin Ibba - 2007-08-01
    • status: open --> closed