Add test and patch for issue 21518.