Fixed NullPointerException in TCPConnection caused by concurrent writes