[Java] Fix race condition with connection
[JS] Fix decoding bug