fix my laziness

remove exception handling from filter supports check
This commit is contained in:
Jake Potrebic 2021-05-19 11:43:34 -07:00
parent df509f1b19
commit c606afc144
No known key found for this signature in database
GPG Key ID: 7C58557EC9C421F8
2 changed files with 6 additions and 9 deletions

View File

@ -2,6 +2,7 @@ package io.papermc.hangar.controller.extras.pagination.filters.log;
import io.papermc.hangar.controller.extras.pagination.Filter;
import io.papermc.hangar.controller.extras.pagination.filters.log.LogPageFilter.LogPageFilterInstance;
import org.apache.commons.lang3.math.NumberUtils;
import org.jdbi.v3.core.statement.SqlStatement;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Component;
@ -24,8 +25,7 @@ public class LogPageFilter implements Filter<LogPageFilterInstance> {
@Override
public boolean supports(NativeWebRequest webRequest) {
Long.parseLong(webRequest.getParameter(getSingleQueryParam()));
return true;
return Filter.super.supports(webRequest) && NumberUtils.isDigits(webRequest.getParameter(getSingleQueryParam()));
}
@NotNull

View File

@ -55,13 +55,10 @@ public class RequestPaginationResolver implements HandlerMethodArgumentResolver
if (applicableFilters != null) {
for (Class<? extends Filter<? extends FilterInstance>> filter : applicableFilters) {
Filter<? extends FilterInstance> f = filterRegistry.get(filter);
try {
if (f.supports(webRequest)) {
pagination.getFilters().add(f.create(webRequest));
paramNames.removeAll(f.getQueryParamNames());
}
} catch (Exception ignored) { }
if (f.supports(webRequest)) {
pagination.getFilters().add(f.create(webRequest));
paramNames.removeAll(f.getQueryParamNames());
}
}
}