Program: 25692
Project: 25692
Buggy source:
@Override public ForwardCursorPagedResourceList<ScheduledActivity> getActivityHistoryV2(String healthCode,String activityGuid,DateTime scheduledOnStart,DateTime scheduledOnEnd,String offsetBy,int pageSize){
  checkNotNull(healthCode);
  checkNotNull(scheduledOnStart);
  checkNotNull(scheduledOnEnd);
  checkNotNull(activityGuid);
  if (pageSize < API_MINIMUM_PAGE_SIZE || pageSize > API_MAXIMUM_PAGE_SIZE) {
    throw new BadRequestException(PAGE_SIZE_ERROR);
  }
  DynamoScheduledActivity hashKey=new DynamoScheduledActivity();
  hashKey.setHealthCode(healthCode);
  String start=activityGuid + "String_Node_Str" + scheduledOnStart.toLocalDateTime().toString();
  String end=activityGuid + "String_Node_Str" + scheduledOnEnd.toLocalDateTime().toString();
  Condition dateCondition=new Condition().withComparisonOperator(ComparisonOperator.BETWEEN).withAttributeValueList(new AttributeValue().withS(start),new AttributeValue().withS(end));
  DynamoDBQueryExpression<DynamoScheduledActivity> query=new DynamoDBQueryExpression<DynamoScheduledActivity>().withHashKeyValues(hashKey).withLimit(pageSize).withScanIndexForward(false).withRangeKeyCondition(GUID,dateCondition);
  if (offsetBy != null) {
    Map<String,AttributeValue> map=Maps.newHashMap();
    map.put(HEALTH_CODE,new AttributeValue(healthCode));
    map.put(GUID,new AttributeValue(activityGuid + "String_Node_Str" + offsetBy));
    query.withExclusiveStartKey(map);
  }
  QueryResultPage<DynamoScheduledActivity> queryResult=mapper.queryPage(DynamoScheduledActivity.class,query);
  List<ScheduledActivity> activities=Lists.newArrayListWithCapacity(queryResult.getResults().size());
  for (  DynamoScheduledActivity act : queryResult.getResults()) {
    act.setTimeZone(DateTimeZone.UTC);
    activities.add((ScheduledActivity)act);
  }
  String nextOffsetBy=null;
  if (queryResult.getLastEvaluatedKey() != null) {
    nextOffsetBy=queryResult.getLastEvaluatedKey().get(GUID).getS().split("String_Node_Str",2)[1];
  }
  return new ForwardCursorPagedResourceList<ScheduledActivity>(activities,nextOffsetBy,pageSize).withFilter(SCHEDULED_ON_START,scheduledOnStart).withFilter(SCHEDULED_ON_END,scheduledOnEnd);
}

Fixed version (ground truth):
@Override public ForwardCursorPagedResourceList<ScheduledActivity> getActivityHistoryV2(String healthCode,String activityGuid,DateTime scheduledOnStart,DateTime scheduledOnEnd,DateTimeZone timezone,String offsetBy,int pageSize){
  checkNotNull(healthCode);
  checkNotNull(scheduledOnStart);
  checkNotNull(scheduledOnEnd);
  checkNotNull(timezone);
  checkNotNull(activityGuid);
  if (pageSize < API_MINIMUM_PAGE_SIZE || pageSize > API_MAXIMUM_PAGE_SIZE) {
    throw new BadRequestException(PAGE_SIZE_ERROR);
  }
  DynamoScheduledActivity hashKey=new DynamoScheduledActivity();
  hashKey.setHealthCode(healthCode);
  String start=activityGuid + "String_Node_Str" + scheduledOnStart.toLocalDateTime().toString();
  String end=activityGuid + "String_Node_Str" + scheduledOnEnd.toLocalDateTime().toString();
  Condition dateCondition=new Condition().withComparisonOperator(ComparisonOperator.BETWEEN).withAttributeValueList(new AttributeValue().withS(start),new AttributeValue().withS(end));
  DynamoDBQueryExpression<DynamoScheduledActivity> query=new DynamoDBQueryExpression<DynamoScheduledActivity>().withHashKeyValues(hashKey).withLimit(pageSize).withScanIndexForward(false).withRangeKeyCondition(GUID,dateCondition);
  if (offsetBy != null) {
    Map<String,AttributeValue> map=Maps.newHashMap();
    map.put(HEALTH_CODE,new AttributeValue(healthCode));
    map.put(GUID,new AttributeValue(activityGuid + "String_Node_Str" + offsetBy));
    query.withExclusiveStartKey(map);
  }
  QueryResultPage<DynamoScheduledActivity> queryResult=mapper.queryPage(DynamoScheduledActivity.class,query);
  List<ScheduledActivity> activities=Lists.newArrayListWithCapacity(queryResult.getResults().size());
  for (  DynamoScheduledActivity act : queryResult.getResults()) {
    act.setTimeZone(timezone);
    activities.add((ScheduledActivity)act);
  }
  String nextOffsetBy=null;
  if (queryResult.getLastEvaluatedKey() != null) {
    nextOffsetBy=queryResult.getLastEvaluatedKey().get(GUID).getS().split("String_Node_Str",2)[1];
  }
  return new ForwardCursorPagedResourceList<ScheduledActivity>(activities,nextOffsetBy,pageSize).withFilter(SCHEDULED_ON_START,scheduledOnStart).withFilter(SCHEDULED_ON_END,scheduledOnEnd);
}