04 January 2019

Busy Socket

Common issue when reading from a socket without timeout:

"main" prio=10 tid=0x00007f79a4009800 nid=0x32ec runnable [0x00007f79aa67a000]
   java.lang.Thread.State: RUNNABLE
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:153)
    at java.net.SocketInputStream.read(SocketInputStream.java:122)
    at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2664)
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2680)
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:3157)
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:865)
    at java.io.ObjectInputStream.(ObjectInputStream.java:362)
    at com.sun.btrace.client.Client.submit(Client.java:402)
    at com.sun.btrace.client.Main.main(Main.java:206)


      sock.setSoTimeout(5 * 1000); //milliseconds

Other details on sockets:

03 January 2019

Btrace cheat sheet

Btrace is a not very popular and powerful tool to debug class at runtime.

The plugin must be installed to run it from visualvm:

Second button to execute it:

Copy the script to be executed thru btrace :

See the results:

It can be executed through command line as well:

btrace <pid> <btrace-script>

$ ./btrace -v -p 2020 -d ./dump/ 64834 TracingScript.java 

More info:
  1. https://github.com/btraceio/btrace
  2. https://dzone.com/articles/btrace-hidden-gem-java
  3. https://www.zcfy.cc/original/btrace-wiki-userguide-mdash-project-kenai

My Blog List

Blog Archive


The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.