#3156 patch for master-2.5