当您在Java中使用RMI时,异常的远程堆栈跟踪将在您收到时添加,有点像这样:
ERROR Client received error when doing stuff:
myapp.FooBarException: bla
at server.myMethod()
at rmi.callHandler() // and now, on the next line comes the client
at rmi.sendCall();
at client.doServerMethod()
at Thread.run()
Run Code Online (Sandbox Code Playgroud)
这种堆栈跟踪"伪造"怎么办?
我想要它是什么(除了被激活之外)?好吧,如果我能做到这一点,它会对我有所帮助:
outer() {
thread = new Thread(...
inner();
// inner() throws
// RuntimeException
// at inner();
// at Runnable.run();
// at Thread.run();
// at outer();
// at lalalala();
// ...
).start();
thread.join();
}
Run Code Online (Sandbox Code Playgroud)
而让这个抛出的异常inner()必须outer()(和方法降低下来链)的堆栈跟踪为好,可以进行日志记录.