backport #6199 to 2.3.0