fix undefined check in setKeepAlive