Reapply r172878 with test case.