Fixes an issue reported in #22576. (cherry picked from commit eb9752d2) (cherry picked from commit a7ec2be1)