Fix not to throw NPE if username or password is null

The java6 & java8 trees were not in sync regarding this issue; copied the legit-looking java6 version over the broken java8 one.