Skip to content

Commit

Permalink
bulk: check targets for empty strings
Browse files Browse the repository at this point in the history
Motivation:

When specifying empty target the bulk proceeds to process
the request instead of failing fast.

Modification:

Fix parsing of target string arguments.

Result:

Fail fast with invalid request

Patch: https://rb.dcache.org/r/14312/
Acked-by: Tigran
Target: trunk
Request: 10.x, 9.x
  • Loading branch information
DmitryLitvintsev committed Sep 4, 2024
1 parent 345edef commit 45a6cc1
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -595,14 +595,24 @@ private static List<String> extractTarget(Map map) {
int close = stringTarget.indexOf("]");
stringTarget = stringTarget.substring(open+1, close);
}
return Arrays.stream(stringTarget.split("[,]")).collect(Collectors.toList());
return Arrays.stream(stringTarget.split("[,]"))
.filter(i-> !i.isEmpty())
.collect(Collectors.toList());
} else if (target instanceof String[]) {
return Arrays.stream(((String) target).split("[,]")).collect(Collectors.toList());
return Arrays.stream(((String) target).split("[,]"))
.map(String::strip)
.filter(i-> !i.isEmpty())
.collect(Collectors.toList());
} else {
return (List<String>) target;
return ((List<String>) target)
.stream()
.map(String::strip)
.filter(i -> !i.isEmpty())
.collect(Collectors.toList());
}
}


private static <T> T removeEntry(Map map, Class<T> clzz, String... names) {
T value = null;
for (String name : names) {
Expand Down

0 comments on commit 45a6cc1

Please sign in to comment.