This is an automated email from the ASF dual-hosted git repository.
gian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new 5b519f3689 Fix null message handling in
AllowedRegexErrorResponseTransformStrategy. (#13177)
5b519f3689 is described below
commit 5b519f3689b750f3119e115dd6c5a6a02ce237b1
Author: Gian Merlino <[email protected]>
AuthorDate: Sun Oct 9 07:42:41 2022 -0700
Fix null message handling in AllowedRegexErrorResponseTransformStrategy.
(#13177)
Error messages can be null. If the incoming error message is null, then
return null.
---
.../exception/AllowedRegexErrorResponseTransformStrategy.java | 3 ++-
.../AllowedRegexErrorResponseTransformStrategyTest.java | 10 ++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git
a/core/src/main/java/org/apache/druid/common/exception/AllowedRegexErrorResponseTransformStrategy.java
b/core/src/main/java/org/apache/druid/common/exception/AllowedRegexErrorResponseTransformStrategy.java
index dde76bddf7..43b7b14325 100644
---
a/core/src/main/java/org/apache/druid/common/exception/AllowedRegexErrorResponseTransformStrategy.java
+++
b/core/src/main/java/org/apache/druid/common/exception/AllowedRegexErrorResponseTransformStrategy.java
@@ -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;
diff --git
a/core/src/test/java/org/apache/druid/common/exception/AllowedRegexErrorResponseTransformStrategyTest.java
b/core/src/test/java/org/apache/druid/common/exception/AllowedRegexErrorResponseTransformStrategyTest.java
index 9ababc860b..3f3fbeca1c 100644
---
a/core/src/test/java/org/apache/druid/common/exception/AllowedRegexErrorResponseTransformStrategyTest.java
+++
b/core/src/test/java/org/apache/druid/common/exception/AllowedRegexErrorResponseTransformStrategyTest.java
@@ -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()
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]