相关疑难解决方法(0)

在Java中伪造堆栈跟踪

当您在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()(和方法降低下来链)的堆栈跟踪为好,可以进行日志记录.

java rpc exception-handling rmi stack-trace

7
推荐指数
1
解决办法
3014
查看次数

标签 统计

exception-handling ×1

java ×1

rmi ×1

rpc ×1

stack-trace ×1