Skip to content

Commit ccb990f

Browse files
chickenljcvictory
authored andcommittedMay 24, 2019
add miss-deleted snippet from #2956 (#4137)
1 parent 8321c8f commit ccb990f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
 

‎dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/AppResponse.java

+18
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.apache.dubbo.rpc;
1818

1919
import java.io.Serializable;
20+
import java.lang.reflect.Field;
2021
import java.util.HashMap;
2122
import java.util.Map;
2223
import java.util.function.Function;
@@ -64,6 +65,23 @@ public AppResponse(Throwable exception) {
6465
@Override
6566
public Object recreate() throws Throwable {
6667
if (exception != null) {
68+
// fix issue#619
69+
try {
70+
// get Throwable class
71+
Class clazz = exception.getClass();
72+
while (!clazz.getName().equals(Throwable.class.getName())) {
73+
clazz = clazz.getSuperclass();
74+
}
75+
// get stackTrace value
76+
Field stackTraceField = clazz.getDeclaredField("stackTrace");
77+
stackTraceField.setAccessible(true);
78+
Object stackTrace = stackTraceField.get(exception);
79+
if (stackTrace == null) {
80+
exception.setStackTrace(new StackTraceElement[0]);
81+
}
82+
} catch (Exception e) {
83+
// ignore
84+
}
6785
throw exception;
6886
}
6987
return result;

0 commit comments

Comments
 (0)
Please sign in to comment.