Skip to content

Commit

Permalink
Fix : Handle Index out of bounds exception in feed api (#19079)
Browse files Browse the repository at this point in the history
* Fix : Handle exception in feed api

* use nullorEmpty
  • Loading branch information
sonika-shah authored Dec 16, 2024
1 parent 17e5331 commit 10301f2
Showing 1 changed file with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -751,19 +751,21 @@ public ResultList<Thread> list(

String beforeCursor = null;
String afterCursor = null;
if (filter.getPaginationType() == PaginationType.BEFORE) {
if (threads.size()
> limit) { // If extra result exists, then previous page exists - return before cursor
threads.remove(0);
beforeCursor = threads.get(0).getUpdatedAt().toString();
}
afterCursor = threads.get(threads.size() - 1).getUpdatedAt().toString();
} else {
beforeCursor = filter.getAfter() == null ? null : threads.get(0).getUpdatedAt().toString();
if (threads.size()
> limit) { // If extra result exists, then next page exists - return after cursor
threads.remove(limit);
afterCursor = threads.get(limit - 1).getUpdatedAt().toString();
if (!nullOrEmpty(threads)) {
if (filter.getPaginationType() == PaginationType.BEFORE) {
if (threads.size()
> limit) { // If extra result exists, then previous page exists - return before cursor
threads.remove(0);
beforeCursor = threads.get(0).getUpdatedAt().toString();
}
afterCursor = threads.get(threads.size() - 1).getUpdatedAt().toString();
} else {
beforeCursor = filter.getAfter() == null ? null : threads.get(0).getUpdatedAt().toString();
if (threads.size()
> limit) { // If extra result exists, then next page exists - return after cursor
threads.remove(limit);
afterCursor = threads.get(limit - 1).getUpdatedAt().toString();
}
}
}
return new ResultList<>(threads, beforeCursor, afterCursor, total);
Expand Down

0 comments on commit 10301f2

Please sign in to comment.