Handle the case where one username is null and the other is not.
Change shutdown() to close() to avoid IDE warning about unclosed resources.