Forward port of issue #20686 to 2.3.0.