Forward port of issue #20714 to 2.3.0.