Forward port of issue #48227 to 4.0.x.
Forward port of issue #48227 to 4.0.x.