If key is null this will throw a NullPointerException. A better way to do this could be if (Constants.MAP_MEMORY_MB_CONF_KEY.equals(key)). Similarly for reduce memory mb.