Back port of #35552 to 2.5.x.
Back port of #35552 to 2.5.x.