How to shutdown btrace?

335 Views Asked by At

I'm using btrace to instrument an application. What Btrace does is inject bytecode into the running JVM to trace the target application. It also sets up a socket connection to communicate between the tracer client and the application.

When I stop the tracer client it does not remove the code injected into the application. It continues to trace and send back the results over this port. Since client is no longer there any attempts to send trace results generate exception:

java.net.SocketException: Connection reset by peer: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
    at java.io.ObjectOutputStream$BlockDataOutputStream.writeBlockHeader(ObjectOutputStream.java:1894)
    at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1875)
    at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1786)
    at java.io.ObjectOutputStream.reset(ObjectOutputStream.java:500)
    at com.sun.btrace.agent.RemoteClient.onCommand(RemoteClient.java:137)
    at com.sun.btrace.BTraceRuntime$ConsumerWrapper.accept(BTraceRuntime.java:169)
    at com.sun.btrace.BTraceRuntime$ConsumerWrapper.accept(BTraceRuntime.java:157)
    at com.sun.btrace.org.jctools.queues.MpscChunkedArrayQueue.drain(MpscChunkedArrayQueue.java:624)
    at com.sun.btrace.BTraceRuntime$4.run(BTraceRuntime.java:443)
    at java.lang.Thread.run(Thread.java:745)

How can I un-instrument the application and gracefully shutdown btrace after connecting it to an application?

0

There are 0 best solutions below