Forward port of issue #21446 to 2.3.0.