Backport to maintenance branch Fix/3.x/issue 3704