From 8dfed4048c90f7d174a480ca9bb66c7824732cfb Mon Sep 17 00:00:00 2001 From: maximthomas Date: Mon, 27 Jun 2022 16:06:56 +0300 Subject: [PATCH] allow regexp match multiline entity --- .../forgerock/openig/regex/StreamPatternMatches.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/openig-core/src/main/java/org/forgerock/openig/regex/StreamPatternMatches.java b/openig-core/src/main/java/org/forgerock/openig/regex/StreamPatternMatches.java index db0f16af0..669298ec1 100644 --- a/openig-core/src/main/java/org/forgerock/openig/regex/StreamPatternMatches.java +++ b/openig-core/src/main/java/org/forgerock/openig/regex/StreamPatternMatches.java @@ -26,6 +26,7 @@ import java.util.NoSuchElementException; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; /** * Iterates through multiple regular expression matches within a character stream. @@ -119,12 +120,9 @@ private void notClosed() throws IOException { private void readahead() throws IOException { notClosed(); - while (matches == null || !matches.hasNext()) { - String line = input.readLine(); - if (line == null) { - break; - } - matches = new StringPatternMatches(line, Arrays.asList(patterns), discard); + if (matches == null || !matches.hasNext()) { + String body = input.lines().collect(Collectors.joining("\n")); + matches = new StringPatternMatches(body, Arrays.asList(patterns), discard); } } }