|
26 | 26 | import org.joni.Regex;
|
27 | 27 | import org.joni.Region;
|
28 | 28 | import org.joni.Syntax;
|
29 |
| -import org.joni.exception.ValueException; |
30 | 29 |
|
31 | 30 | import java.io.BufferedReader;
|
32 | 31 | import java.io.IOException;
|
@@ -150,17 +149,14 @@ private void forbidCircularReferences(String patternName, List<String> path, Str
|
150 | 149 | }
|
151 | 150 |
|
152 | 151 | public String groupMatch(String name, Region region, String pattern) {
|
153 |
| - try { |
154 |
| - int number = GROK_PATTERN_REGEX.nameToBackrefNumber(name.getBytes(StandardCharsets.UTF_8), 0, |
155 |
| - name.getBytes(StandardCharsets.UTF_8).length, region); |
156 |
| - int begin = region.beg[number]; |
157 |
| - int end = region.end[number]; |
158 |
| - return new String(pattern.getBytes(StandardCharsets.UTF_8), begin, end - begin, StandardCharsets.UTF_8); |
159 |
| - } catch (StringIndexOutOfBoundsException e) { |
160 |
| - return null; |
161 |
| - } catch (ValueException e) { |
| 152 | + int number = GROK_PATTERN_REGEX.nameToBackrefNumber(name.getBytes(StandardCharsets.UTF_8), 0, |
| 153 | + name.getBytes(StandardCharsets.UTF_8).length, region); |
| 154 | + int begin = region.beg[number]; |
| 155 | + int end = region.end[number]; |
| 156 | + if (begin < 0) { // no match found |
162 | 157 | return null;
|
163 | 158 | }
|
| 159 | + return new String(pattern.getBytes(StandardCharsets.UTF_8), begin, end - begin, StandardCharsets.UTF_8); |
164 | 160 | }
|
165 | 161 |
|
166 | 162 | /**
|
|
0 commit comments