Open
Description
Describe the bug
The error handling for the sendRequest
method in the StorageImplUtils
assumes that the exception has a cause:
RuntimeException
is thrown with a null cause
Exception or Stack Trace
Just an empty RuntimeException
that gets thrown without a cause from StorageImplUtils#sendRequest
To Reproduce
Steps to reproduce the behavior: I don't believe these are needed
Code Snippet
public static <T> T sendRequest(Callable<T> operation, Duration timeout,
Class<? extends RuntimeException> exceptionType) {
try {
if (timeout == null) {
return operation.call();
}
Future<T> future = SharedExecutorService.getInstance().submit(operation);
return getResultWithTimeout(future, timeout.toMillis(), exceptionType);
} catch (Exception e) {
Throwable cause = e.getCause();
if (exceptionType.isInstance(e)) {
// Safe to cast since we checked with isInstance
throw exceptionType.cast(e);
} else if (cause instanceof RuntimeException) {
// Throw as is if it's already a RuntimeException
throw (RuntimeException) cause;
} else if (cause instanceof Error) {
// Propagate if it's an Error
throw (Error) cause;
} else {
// Wrap in RuntimeException if it's neither Error nor RuntimeException
throw LOGGER.logExceptionAsError(new RuntimeException(cause));
}
}
}
Expected behavior
I expect that if an exception is caught in the sendRequest
method and it doesn't have a cause that the same exception should be rethrown if it is either a runtime exception or an error.
Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- Bug Description Added
- [/] Repro Steps Added
- [/] Setup information Added