backport fix for issue #1802