Fix race when multiple connect are done in parallel

JAVA-261 #fixes