Menu

#10 getAllQualificationsForQualificationType loops forever

open
nobody
Core (5)
5
2012-07-27
2012-07-27
Anonymous
No

If the number of qualifications is more than the length of one page, getAllQualificationsForQualificationType will loop forever because pageNum is never incremented. Just adding pageNum++ at the bottom of the loop fixes it:

public Qualification[] getAllQualificationsForQualificationType(String qualificationTypeId) throws Exception {
List<Qualification> results = new ArrayList<Qualification>();

int pageNum = 1;

do {
Qualification[] qualifications =
this.getQualificationsForQualificationType(qualificationTypeId, pageNum);

if (qualifications != null) {
// Add the results
Collections.addAll(results, qualifications);
}

if (qualifications == null || qualifications.length < DEFAULT_PAGE_SIZE) {
// Check if we're on the last page or not
break;
}

// PATCH
pageNum++;
// ENDPATCH
} while (true);

return (Qualification[]) results.toArray(new Qualification[results.size()]);
}

Discussion


Log in to post a comment.