#9 Bug in getNextEventData(-)? version 2.2.7

closed-fixed
nobody
None
5
2010-12-19
2010-12-16
king
No

Looking into the following method of class EventData, there seems to be a bug at the first line of source code:

[ if ((!validGPS && (this.nextEventData != null)) ]:

Logic/truth: this.nextEventData is used and directly returned only when validGPS is FALSE and this.nextEventData is not NULL,
and this.nextEventData_validGPS is used and directly returned only when validGPS is TRUE and this.nextEventData_validGPS is not NULL;
otherwise, event data will need to be reload from database and then be returned.

However, the above line of source code shows to us that it will still be loaded from database even though this.nextEventData is not NULL
when validGPS is FALSE. On the contrary, it will not be reloaded from database when this.nextEventData is NULL and validGPS is false.

thus, the last line of source code inside this method will return a NULL object when validGPS is FALSE and this.nextEventData is NULL.

It seems to me that this is a bug logically.

- Daniel

--------------------------------------------------------------------------------------------------------------
== EventData.java ==

public EventData getNextEventData(boolean validGPS)
throws DBException
{
if ((!validGPS && (this.nextEventData != null)) ||
( validGPS && (this.nextEventData_validGPS == null))) {
// 'startTime' should be this events timestamp,
// and 'additionalSelect' should be (statusCode != this.getStatusCode())
long startTime = this.getTimestamp() + 1L;
long endTime = -1L;
EventData ed[] = EventData.getRangeEvents(
this.getAccountID(), this.getDeviceID(),
startTime, endTime,
null/*statusCodes[]*/,
validGPS,
EventData.LimitType.FIRST, 1/*limit*/, true/*ascending*/,
null/*additionalSelect*/);
if ((ed != null) && (ed.length > 0)) {
if (validGPS) {
this.nextEventData_validGPS = ed[0];
} else {
this.nextEventData = ed[0];
if (this.nextEventData.isValidGeoPoint()) {
this.nextEventData_validGPS = this.nextEventData;
}
}
}
}
return validGPS? this.nextEventData_validGPS : this.nextEventData;
}

Discussion

  • Martin Flynn
    Martin Flynn
    2010-12-17

    • status: open --> pending-fixed
     
  • Martin Flynn
    Martin Flynn
    2010-12-17

    Thanks for finding this.
    This will be fixed in the next release (v2.3.0)
    Thanks,
    - Martin

     
  • king
    king
    2010-12-19

    • status: pending-fixed --> closed-fixed