Forward port of issue #20759 to 2.3.0.