Avoid re-creating the instance unless it is a bean name that needs to be resolved through the BeanFactory. Closes gh-34277