cherry-pick 237c755b597ada0ead74696a32e4bee7e84ce03c from 2.1.x branch