Forward port of issue #20796 to 2.3.0.