Skip to content

Commit

Permalink
fix #723: not print stack in error log when exception declared in method
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnights committed Jul 10, 2018
1 parent c118231 commit d83ce8b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public Response invoke(Request request) {
return response;
}

boolean defaultThrowExceptionStack = URLParamType.transExceptionStack.getBooleanValue();
try {
Object value = method.invoke(proxyImpl, request.getArguments());
response.setValue(value);
Expand All @@ -69,11 +70,12 @@ public Response invoke(Request request) {
response.setException(new MotanBizException("provider call process error", e));
}

// not print detail error when exception declared in method
// not print stack in error log when exception declared in method
boolean logException = true;
for (Class<?> clazz : method.getExceptionTypes()) {
if (e.getCause().getClass() == clazz) {
if (response.getException().getCause().getClass() == clazz) {
logException = false;
defaultThrowExceptionStack = false;
break;
}
}
Expand All @@ -95,7 +97,7 @@ public Response invoke(Request request) {

if (response.getException() != null) {
//是否传输业务异常栈
boolean transExceptionStack = this.url.getBooleanParameter(URLParamType.transExceptionStack.getName(), URLParamType.transExceptionStack.getBooleanValue());
boolean transExceptionStack = this.url.getBooleanParameter(URLParamType.transExceptionStack.getName(), defaultThrowExceptionStack);
if (!transExceptionStack) {//不传输业务异常栈
ExceptionUtil.setMockStackTrace(response.getException().getCause());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public String hello(String name) {
}

@Override
public User rename(User user, String name) {
public User rename(User user, String name) throws NullPointerException {
Objects.requireNonNull(user);
System.out.println(user.getId() + " rename " + user.getName() + " to " + name);
user.setName(name);
Expand Down

0 comments on commit d83ce8b

Please # to comment.