Backport to 1.8 3657

Backport #3657 to 1.8.x.