mirror of https://github.com/apache/druid.git
Fix null message handling in AllowedRegexErrorResponseTransformStrategy. (#13177)
Error messages can be null. If the incoming error message is null, then return null.
This commit is contained in:
parent
573e12c75f
commit
5b519f3689
|
@ -51,7 +51,8 @@ public class AllowedRegexErrorResponseTransformStrategy implements ErrorResponse
|
|||
public Function<String, String> getErrorMessageTransformFunction()
|
||||
{
|
||||
return (String errorMessage) -> {
|
||||
if (allowedRegexPattern.stream().anyMatch(pattern -> pattern.matcher(errorMessage).matches())) {
|
||||
if (errorMessage == null || allowedRegexPattern.stream()
|
||||
.anyMatch(pattern -> pattern.matcher(errorMessage).matches())) {
|
||||
return errorMessage;
|
||||
} else {
|
||||
return null;
|
||||
|
|
|
@ -59,6 +59,16 @@ public class AllowedRegexErrorResponseTransformStrategyTest
|
|||
Assert.assertNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetErrorMessageTransformFunctionWithNullMessage()
|
||||
{
|
||||
AllowedRegexErrorResponseTransformStrategy allowedRegex = new AllowedRegexErrorResponseTransformStrategy(
|
||||
ImmutableList.of("acbd", "qwer")
|
||||
);
|
||||
String result = allowedRegex.getErrorMessageTransformFunction().apply(null);
|
||||
Assert.assertNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsAndHashCode()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue