guard against empty input
limit the number of retries
[bamboo] Automated branch merge (from pjsm/2.0:7c32c3a7bb5c709634912e56f692120941ee80b3)