Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve npe exception when request params are matched and removed. #365

Closed
wants to merge 1 commit into from
Closed
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 @@ -65,12 +65,12 @@
}
List<String> values = requestParams.get(name);
if(CollectionUtil.isEmpty(values)){
return false;

Check warning on line 68 in arex-instrumentation/servlet/arex-httpservlet/src/main/java/io/arex/inst/httpservlet/ServletUtil.java

View check run for this annotation

Codecov / codecov/patch

arex-instrumentation/servlet/arex-httpservlet/src/main/java/io/arex/inst/httpservlet/ServletUtil.java#L68

Added line #L68 was not covered by tests
}
Iterator<String> iterator = values.iterator();
while (iterator.hasNext()) {
String next = iterator.next();
if (next.equals(value)) {
if (next != null && next.equals(value)) {
iterator.remove();
return true;
}
Expand All @@ -86,7 +86,7 @@
*/
public static Map<String, List<String>> getRequestParams(String queryString) {
if (StringUtil.isEmpty(queryString)) {
return Collections.emptyMap();

Check warning on line 89 in arex-instrumentation/servlet/arex-httpservlet/src/main/java/io/arex/inst/httpservlet/ServletUtil.java

View check run for this annotation

Codecov / codecov/patch

arex-instrumentation/servlet/arex-httpservlet/src/main/java/io/arex/inst/httpservlet/ServletUtil.java#L89

Added line #L89 was not covered by tests
}
MultiValueMap<String, String> paramsKeyValueMap = UriComponentsBuilder.fromUriString(
"?" + queryString).build().getQueryParams();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void getFullPath() {
@Test
public void matchRequestParams() {
Map<String, List<String>> requestParams = new HashMap<>();
requestParams.put("name", new ArrayList<>(Arrays.asList("kimi")));
requestParams.put("name", new ArrayList<>(Arrays.asList("kimi", null)));
requestParams.put("age", new ArrayList<>(Arrays.asList("0")));
assertFalse(ServletUtil.matchAndRemoveRequestParams(requestParams, "name", "lock"));
assertTrue(ServletUtil.matchAndRemoveRequestParams(requestParams, "age", "0"));
Expand Down
Loading