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