Skip to content

Commit f27f8e5

Browse files
fix: stop stringifying callstack (#51)
1 parent 87a306b commit f27f8e5

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

grpc-server-utils/src/main/java/org/hypertrace/core/grpcutils/server/ThrowableResponseInterceptor.java

+2-12
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import io.grpc.ServerCallHandler;
77
import io.grpc.ServerInterceptor;
88
import io.grpc.Status;
9-
import java.io.PrintWriter;
10-
import java.io.StringWriter;
119

1210
/** Server Interceptor that decorates the error response status before closing the call */
1311
public class ThrowableResponseInterceptor implements ServerInterceptor {
@@ -26,23 +24,15 @@ public void close(Status status, Metadata trailers) {
2624
if (status.getCode() == Status.Code.UNKNOWN
2725
&& status.getDescription() == null
2826
&& status.getCause() != null) {
29-
Throwable e = status.getCause();
3027
status =
3128
Status.INTERNAL
32-
.withDescription(e.getMessage())
33-
.augmentDescription(stacktraceToString(e));
29+
.withDescription(status.getCause().getMessage())
30+
.withCause(status.getCause());
3431
}
3532
super.close(status, trailers);
3633
}
3734
};
3835

3936
return next.startCall(wrappedCall, headers);
4037
}
41-
42-
private String stacktraceToString(Throwable e) {
43-
StringWriter stringWriter = new StringWriter();
44-
PrintWriter printWriter = new PrintWriter(stringWriter);
45-
e.printStackTrace(printWriter);
46-
return stringWriter.toString();
47-
}
4838
}

0 commit comments

Comments
 (0)