The returned name can't be null, so there is no need to do the null check. It isn't your mistake since you only cleaned up the code. Also if you do multiple 'getXXX' I store them in a local variable to prevent the overhead of potential multiple method calls. It depends a bit on the jit how much things are being optimised.