cherry-picked from b8e2e2e46c94f30d7b7d0ca9fcc7ee4a44664449