Skip to content

Commit

Permalink
String#split limits are a bit surprising.
Browse files Browse the repository at this point in the history
Limit 1  means a single element in the resulting array.

Signed-off-by: Sam Barker <[email protected]>

rh-pre-commit.version: 2.0.1
rh-pre-commit.check-secrets: ENABLED
  • Loading branch information
SamBarker committed Jul 16, 2024
1 parent f6960f7 commit 1bd3a43
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private Stream<String> extractRecordLinesFromLog(String log) {
return Stream.of(log.split("\n"))
.filter(l -> l.contains(stringToSeek))
.map(line -> {
final String[] split = line.split(stringToSeek, 1);
final String[] split = line.split(stringToSeek, 2); // Limit is 1 based so a limit of 2 means use the seek at most 1 times
if (split.length > 1) {
return split[1];
}
Expand Down

0 comments on commit 1bd3a43

Please sign in to comment.