Cherry-picked 9131eb825dddb40c1669dc7d04072724ac11d8e0.