apache / apache/dubbo

org.apache.dubbo.rpc.filter.ExceptionFilter should't change the RuntimeException again

Open
#9,677 2 comments 0 reactions 0 assignees View on GitHub
type/proposal
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

suggest ExceptionFilter should't change the RuntimeException again

// directly throw if it's checked exception
if (!(exception instanceof RuntimeException) && (exception instanceof Exception)) {
return;
}
//ellipsis some code
// otherwise, wrap with RuntimeException and throw back to the client
appResponse.setException(new RuntimeException(StringUtils.toString(exception)));
------------------
on this code it change the Exception
I don't know what purpose of change the Exception,especially when this Exception instanceof RuntimeException,It just wrap it again
If you want to send some message by Exception,a instanceof of RuntimeException is a good choice.
It don't need to declare on every method,but catch on the global exception handler
For example,if you use java proxy,it auto generate a class like that if you has no exception appears in the signature:
try {
super.h.invoke(this, m3, (Object[])null);
} catch (RuntimeException | Error var2) {
throw var2;
} catch (Throwable var3) {
throw new UndeclaredThrowableException(var3);
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.