Forward port of issue #17001 to 2.3.0.