Forward port of issue #46877 to 3.5.x.
Forward port of issue #46877 to 3.5.x.