Backport fix for #8243 to release-12.1
Backport fix for #8243 to release-12.1