Maybe put the code in try/finally to make sure the client is removed from the map even if an exception occurs.