Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ public ResultList<T> listAfter(
if (limitParam > 0) {
// forward scrolling, if after == null then first page is being asked
Map<String, String> cursorMap =
parseCursorMap(after == null ? "" : RestUtil.decodeCursor(after));
parseCursorMap(after == null || after.isEmpty() ? "" : RestUtil.decodeCursor(after));
String afterName = FullyQualifiedName.unquoteName(cursorMap.get("name"));
String afterId = cursorMap.get("id");
List<String> jsons = dao.listAfter(filter, limitParam + 1, afterName, afterId);
Expand All @@ -1019,7 +1019,7 @@ public ResultList<T> listAfter(

String beforeCursor;
String afterCursor = null;
beforeCursor = after == null ? null : getCursorValue(entities.get(0));
beforeCursor = after == null || after.isEmpty() ? null : getCursorValue(entities.get(0));
if (entities.size()
> limitParam) { // If extra result exists, then next page exists - return after cursor
entities.remove(limitParam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ private String getBeforeOffset(int offsetInt, int limit) {
}

private int getOffset(String offset) {
return offset != null ? Integer.parseInt(RestUtil.decodeCursor(offset)) : 0;
String decoded = RestUtil.decodeCursor(offset);
return offset != null && decoded != null ? Integer.parseInt(decoded) : 0;
}

private Map<String, List<?>> getEntityList(List<String> jsons, boolean skipErrors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ public static String encodeCursor(String cursor) {
}

public static String decodeCursor(String cursor) {
return cursor == null ? null : new String(Base64.getUrlDecoder().decode(cursor));
return cursor == null || cursor.isEmpty()
? null
: new String(Base64.getUrlDecoder().decode(cursor));
}

public static class PutResponse<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public static Jdbi createAndSetupJDBI(DataSourceFactory dbFactory) {
}

public static int getOffset(String offset) {
return offset != null ? Integer.parseInt(RestUtil.decodeCursor(offset)) : 0;
String decoded = RestUtil.decodeCursor(offset);
return offset != null && decoded != null ? Integer.parseInt(decoded) : 0;
}

public static String getAfterOffset(int offsetInt, int limit, int total) {
Expand Down
Loading