mirror of https://github.com/apache/druid.git
get rid of class cast exception and add a new testcase for that issue (#11951)
This commit is contained in:
parent
0a9a908031
commit
a4cb1de87a
|
@ -78,7 +78,7 @@ class ErrorHandler
|
|||
return new RuntimeException(errorResponseTransformStrategy.transformIfNeeded((SanitizableException) error.getCause()));
|
||||
}
|
||||
QueryInterruptedException wrappedError = QueryInterruptedException.wrapIfNeeded(error);
|
||||
return (QueryInterruptedException) errorResponseTransformStrategy.transformIfNeeded(wrappedError);
|
||||
return (QueryException) errorResponseTransformStrategy.transformIfNeeded(wrappedError);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -78,4 +78,20 @@ public class ErrorHandlerTest
|
|||
ErrorHandler errorHandler = new ErrorHandler(serverConfig);
|
||||
Assert.assertFalse(errorHandler.hasAffectingErrorResponseTransformStrategy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorHandlerHandlesNonSanitizableExceptionCorrectly()
|
||||
{
|
||||
ServerConfig serverConfig = Mockito.mock(ServerConfig.class);
|
||||
AllowedRegexErrorResponseTransformStrategy emptyAllowedRegexErrorResponseTransformStrategy = new AllowedRegexErrorResponseTransformStrategy(
|
||||
ImmutableList.of());
|
||||
|
||||
Mockito.when(serverConfig.getErrorResponseTransformStrategy())
|
||||
.thenReturn(emptyAllowedRegexErrorResponseTransformStrategy);
|
||||
ErrorHandler errorHandler = new ErrorHandler(serverConfig);
|
||||
|
||||
Exception input = new Exception("message");
|
||||
RuntimeException output = errorHandler.sanitize(input);
|
||||
Assert.assertEquals(null, output.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue