Forward port of issue #20333 to 2.3.1.