Skip to content

Commit

Permalink
Fix(#3239) NPE, for RegexFilter creator.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaykataria1111 committed Dec 13, 2024
1 parent 0f48f60 commit 39051d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -39,6 +40,13 @@ static void before() {
StatusLogger.getLogger().setLevel(Level.OFF);
}

@Test
void testRegexFilterDoesNotThrowWithAllTheParametersExceptRegexEqualNull() {
assertDoesNotThrow(() -> {
RegexFilter.createFilter(".* test .*", null, null, null, null);
});
}

@Test
void testThresholds() throws Exception {
RegexFilter filter = RegexFilter.createFilter(".* test .*", null, false, null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ public static RegexFilter createFilter(
LOGGER.error("A regular expression must be provided for RegexFilter");
return null;
}
return new RegexFilter(useRawMsg, Pattern.compile(regex, toPatternFlags(patternFlags)), match, mismatch);
return new RegexFilter(
Boolean.TRUE.equals(useRawMsg), Pattern.compile(regex, toPatternFlags(patternFlags)), match, mismatch);
}

private static int toPatternFlags(final String[] patternFlags)
Expand Down

0 comments on commit 39051d2

Please sign in to comment.