Apply bug25509 on stable branch